完善采购订单

This commit is contained in:
2024-06-11 22:43:29 +08:00
parent a091be8e05
commit bc4d3c0f62
18 changed files with 588 additions and 149 deletions

View File

@@ -0,0 +1,54 @@
package cn.lihongjie.coal.organizationConfig.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.organizationConfig.dto.CreateOrganizationConfigDto;
import cn.lihongjie.coal.organizationConfig.dto.OrganizationConfigDto;
import cn.lihongjie.coal.organizationConfig.dto.UpdateOrganizationConfigDto;
import cn.lihongjie.coal.organizationConfig.service.OrganizationConfigService;
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("/organizationConfig")
@SysLog(module = "机构配置信息")
@Slf4j
@OrgScope
public class OrganizationConfigController {
@Autowired private OrganizationConfigService service;
@PostMapping("/create")
public OrganizationConfigDto create(@RequestBody CreateOrganizationConfigDto request) {
return this.service.create(request);
}
@PostMapping("/update")
public OrganizationConfigDto update(@RequestBody UpdateOrganizationConfigDto request) {
return this.service.update(request);
}
@PostMapping("/delete")
public Object delete(@RequestBody IdRequest request) {
this.service.delete(request);
return true;
}
@PostMapping("/getById")
public OrganizationConfigDto getById(@RequestBody IdRequest request) {
return this.service.getById(request.getId());
}
@PostMapping("/list")
public Page<OrganizationConfigDto> list(@RequestBody CommonQuery request) {
return this.service.list(request);
}
}

View File

@@ -0,0 +1,29 @@
package cn.lihongjie.coal.organizationConfig.dto;
import cn.lihongjie.coal.base.dto.OrgCommonDto;
import lombok.Data;
import org.hibernate.annotations.Comment;
@Data
public class CreateOrganizationConfigDto extends OrgCommonDto {
@Comment("采购订单号生成规则 0 手工填写 1 全局递增 2 年月日+递增 3 年月日时分秒 ")
private String purchaseOrderNoRule;
@Comment("采购订单号前缀")
private String purchaseOrderNoPrefix;
@Comment("采购订单号递增步长")
private Integer purchaseOrderNoStep;
@Comment("采购订单号递增起始值")
private Integer purchaseOrderNoStart;
@Comment("递增部分位数")
private Integer purchaseOrderNoAutoIncrLength;
}

View File

@@ -0,0 +1,28 @@
package cn.lihongjie.coal.organizationConfig.dto;
import cn.lihongjie.coal.base.dto.OrgCommonDto;
import lombok.Data;
import org.hibernate.annotations.Comment;
@Data
public class OrganizationConfigDto extends OrgCommonDto {
@Comment("采购订单号生成规则 0 手工填写 1 全局递增 2 年月日+递增 3 年月日时分秒 ")
private String purchaseOrderNoRule;
@Comment("采购订单号前缀")
private String purchaseOrderNoPrefix;
@Comment("采购订单号递增步长")
private Integer purchaseOrderNoStep;
@Comment("采购订单号递增起始值")
private Integer purchaseOrderNoStart;
@Comment("递增部分位数")
private Integer purchaseOrderNoAutoIncrLength;
}

View File

@@ -0,0 +1,29 @@
package cn.lihongjie.coal.organizationConfig.dto;
import cn.lihongjie.coal.base.dto.OrgCommonDto;
import lombok.Data;
import org.hibernate.annotations.Comment;
@Data
public class UpdateOrganizationConfigDto extends OrgCommonDto {
@Comment("采购订单号生成规则 0 手工填写 1 全局递增 2 年月日+递增 3 年月日时分秒 ")
private String purchaseOrderNoRule;
@Comment("采购订单号前缀")
private String purchaseOrderNoPrefix;
@Comment("采购订单号递增步长")
private Integer purchaseOrderNoStep;
@Comment("采购订单号递增起始值")
private Integer purchaseOrderNoStart;
@Comment("递增部分位数")
private Integer purchaseOrderNoAutoIncrLength;
}

View File

@@ -0,0 +1,53 @@
package cn.lihongjie.coal.organizationConfig.entity;
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
import jakarta.persistence.Entity;
import lombok.Data;
import org.hibernate.annotations.Comment;
@Data
@Entity
public class OrganizationConfigEntity extends OrgCommonEntity {
@Comment("采购订单号生成规则 0 手工填写 1 全局递增 2 年月日+递增 3 年月日时分秒 ")
private String purchaseOrderNoRule;
@Comment("采购订单号前缀")
private String purchaseOrderNoPrefix;
@Comment("采购订单号递增步长")
private Integer purchaseOrderNoStep;
@Comment("采购订单号递增起始值")
private Integer purchaseOrderNoStart;
@Comment("递增部分位数")
private Integer purchaseOrderNoAutoIncrLength;
}

View File

@@ -0,0 +1,23 @@
package cn.lihongjie.coal.organizationConfig.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.organizationConfig.dto.CreateOrganizationConfigDto;
import cn.lihongjie.coal.organizationConfig.dto.OrganizationConfigDto;
import cn.lihongjie.coal.organizationConfig.dto.UpdateOrganizationConfigDto;
import cn.lihongjie.coal.organizationConfig.entity.OrganizationConfigEntity;
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 OrganizationConfigMapper
extends BaseMapper<
OrganizationConfigEntity,
OrganizationConfigDto,
CreateOrganizationConfigDto,
UpdateOrganizationConfigDto> {}

View File

@@ -0,0 +1,15 @@
package cn.lihongjie.coal.organizationConfig.repository;
import cn.lihongjie.coal.base.dao.BaseRepository;
import cn.lihongjie.coal.organizationConfig.entity.OrganizationConfigEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface OrganizationConfigRepository extends BaseRepository<OrganizationConfigEntity> {
@Query("select false")
boolean isLinked(List<String> ids);
}

View File

@@ -0,0 +1,124 @@
package cn.lihongjie.coal.organizationConfig.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.dbFunctions.DbFunctionService;
import cn.lihongjie.coal.exception.BizException;
import cn.lihongjie.coal.organizationConfig.dto.CreateOrganizationConfigDto;
import cn.lihongjie.coal.organizationConfig.dto.OrganizationConfigDto;
import cn.lihongjie.coal.organizationConfig.dto.UpdateOrganizationConfigDto;
import cn.lihongjie.coal.organizationConfig.entity.OrganizationConfigEntity;
import cn.lihongjie.coal.organizationConfig.mapper.OrganizationConfigMapper;
import cn.lihongjie.coal.organizationConfig.repository.OrganizationConfigRepository;
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;
import java.util.List;
@Service
@Slf4j
@Transactional
public class OrganizationConfigService
extends BaseService<OrganizationConfigEntity, OrganizationConfigRepository> {
@Autowired private OrganizationConfigRepository repository;
@Autowired private OrganizationConfigMapper mapper;
@Autowired private ConversionService conversionService;
@Autowired private DbFunctionService dbFunctionService;
public OrganizationConfigEntity getCurrentOrgConfig(){
return getOrgConfig(Ctx.currentUser().getOrganizationId());
}
private OrganizationConfigEntity getOrgConfig(String organizationId) {
List<OrganizationConfigEntity> entities = repository.findByOrganizationId(organizationId);
if(entities.size() == 0){
OrganizationConfigEntity entity = initDefault(organizationId);
save(entity);
return entity;
}
return entities.get(0);
}
private OrganizationConfigEntity initDefault(String organizationId) {
OrganizationConfigEntity entity = new OrganizationConfigEntity();
entity.setOrganizationId(organizationId);
entity.setPurchaseOrderNoStep(1);
entity.setPurchaseOrderNoStart(1);
entity.setPurchaseOrderNoRule("2");
entity.setPurchaseOrderNoPrefix("PO");
entity.setPurchaseOrderNoAutoIncrLength(4);
return entity;
}
public OrganizationConfigDto create(CreateOrganizationConfigDto request) {
OrganizationConfigEntity entity = mapper.toEntity(request);
this.repository.save(entity);
return getById(entity.getId());
}
public OrganizationConfigDto update(UpdateOrganizationConfigDto request) {
OrganizationConfigEntity 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 OrganizationConfigDto getById(String id) {
OrganizationConfigEntity entity = repository.get(id);
return mapper.toDto(entity);
}
public Page<OrganizationConfigDto> list(CommonQuery query) {
Page<OrganizationConfigEntity> page =
repository.findAll(
query.specification(conversionService),
PageRequest.of(
query.getPageNo(),
query.getPageSize(),
Sort.by(query.getOrders())));
return page.map(this.mapper::toDto);
}
}

View File

@@ -24,11 +24,23 @@ public class CreatePurchaseOrderDto extends OrgCommonDto {
private Double amount;
@Comment("采购单状态")
private String orderStatus;
@Comment("采购单价")
private Double price;
@Comment("是否含税")
private Boolean includeTax;
@Comment("税率")
private Double taxRate;
@Comment("其他费用")
private Double otherFee;
@Comment("采购日期")
private LocalDate purchaseDate;

View File

@@ -49,6 +49,16 @@ public class PurchaseOrderDto extends OrgCommonDto {
private Double amount;
@Comment("是否含税")
private Boolean includeTax;
@Comment("税率")
private Double taxRate;
@Comment("其他费用")
private Double otherFee;
private Double receivedAmount;
@Comment("收货进度 百分比")

View File

@@ -25,10 +25,23 @@ public class UpdatePurchaseOrderDto extends OrgCommonDto {
private Double amount;
@Comment("采购单状态")
private String orderStatus;
@Comment("采购单价")
private Double price;
@Comment("是否含税")
private Boolean includeTax;
@Comment("税率")
private Double taxRate;
@Comment("其他费用")
private Double otherFee;
@Comment("采购日期")

View File

@@ -2,10 +2,16 @@ package cn.lihongjie.coal.purchaseOrder.dto;
import lombok.Data;
import org.hibernate.annotations.Comment;
import java.util.*;
@Data
public class UpdateWeightDataDto {
@Comment("操作类型 1 新增 2 全量覆盖 3 删除 ")
private String optType;
private String id;
private List<String> weightDataList;
}

View File

@@ -46,13 +46,26 @@ public class PurchaseOrderEntity extends OrgCommonEntity {
private Double amount;
@Comment("是否含税")
private Boolean includeTax;
@Comment("税率")
private Double taxRate;
@Comment("采购单价")
private Double price;
@Formula("(amount * price)")
@Comment("其他费用")
private Double otherFee;
@Formula("((amount * price) + coalesce(other_fee, 0))")
private Double total;
@Comment("采购单状态")
@@ -73,7 +86,15 @@ public class PurchaseOrderEntity extends OrgCommonEntity {
private Double dayAmount;
@Override
public void prePersist() {
super.prePersist();
this.startTime = this.purchaseDate==null ? null: this.purchaseDate.atStartOfDay();
}
@Override
public void preUpdate() {
super.preUpdate();
this.startTime = this.purchaseDate==null ? null: this.purchaseDate.atStartOfDay();
}
}

View File

@@ -3,10 +3,13 @@ package cn.lihongjie.coal.purchaseOrder.repository;
import cn.lihongjie.coal.base.dao.BaseRepository;
import cn.lihongjie.coal.purchaseOrder.entity.PurchaseOrderEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@Repository
public interface PurchaseOrderRepository extends BaseRepository<PurchaseOrderEntity> {
@Query("select (count(p) > 0) from PurchaseOrderEntity p where p.code = ?1 and p.organizationId = ?2")
boolean existsByCodeAndOrganizationId(String code, String organizationId);
}

View File

@@ -2,9 +2,12 @@ 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.mapper.CommonMapper;
import cn.lihongjie.coal.base.service.BaseService;
import cn.lihongjie.coal.common.Ctx;
import cn.lihongjie.coal.common.JpaUtils;
import cn.lihongjie.coal.organizationConfig.entity.OrganizationConfigEntity;
import cn.lihongjie.coal.organizationConfig.service.OrganizationConfigService;
import cn.lihongjie.coal.purchaseOrder.dto.CreatePurchaseOrderDto;
import cn.lihongjie.coal.purchaseOrder.dto.PurchaseOrderDto;
import cn.lihongjie.coal.purchaseOrder.dto.UpdatePurchaseOrderDto;
@@ -12,6 +15,7 @@ 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.sequence.SequenceService;
import cn.lihongjie.coal.weightDeviceData.entity.WeightDeviceDataEntity;
import cn.lihongjie.coal.weightDeviceData.mapper.WeightDeviceDataMapper;
import cn.lihongjie.coal.weightDeviceData.repository.WeightDeviceDataRepository;
@@ -19,10 +23,10 @@ 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.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -33,15 +37,19 @@ import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.time.format.DateTimeFormatter;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
@Service
@Slf4j
@Transactional
public class PurchaseOrderService
extends BaseService<PurchaseOrderEntity, PurchaseOrderRepository> {
@Autowired SequenceService sequenceService;
@Autowired private PurchaseOrderRepository repository;
@Autowired private PurchaseOrderMapper mapper;
@@ -61,46 +69,18 @@ public class PurchaseOrderService
return mapper.toDto(entity);
}
@Autowired OrganizationConfigService organizationConfigService;
@Autowired private CommonMapper commonMapper;
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 {
if (StringUtils.isNotEmpty(request.getCode())) {
if (repository.existsByCodeAndOrganizationId(
request.getCode(), Ctx.currentUser().getOrganizationId())) {
throw new RuntimeException("采购单号已存在");
}
}
this.repository.save(entity);
@@ -110,104 +90,24 @@ public class PurchaseOrderService
public PurchaseOrderDto update(UpdatePurchaseOrderDto request) {
PurchaseOrderEntity entity = this.repository.get(request.getId());
String oldStatus = entity.getOrderStatus();
if (StringUtils.isNotEmpty(request.getCode())) {
if (entityManager
.createQuery(
"select count(p) from PurchaseOrderEntity p where p.code = :code and p.id != :id and p.organizationId = :organizationId",
Long.class)
.setParameter("code", request.getCode())
.setParameter("organizationId", Ctx.currentUser().getOrganizationId())
.setParameter("id", request.getId())
.getSingleResult()
> 0L) {
throw new RuntimeException("采购单号已存在");
}
}
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());
@@ -216,10 +116,51 @@ public class PurchaseOrderService
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());
switch (request.getOptType()) {
case "0" -> {
if (CollectionUtils.isNotEmpty(entity.getWeightDataList())) {
Collection<String> toAdd =
CollectionUtils.removeAll(
request.getWeightDataList(),
entity.getWeightDataList().stream()
.map(x -> x.getId())
.collect(Collectors.toSet()));
entity.getWeightDataList()
.addAll(
toAdd.stream()
.map(
x ->
entityManager.getReference(
WeightDeviceDataEntity.class,
x))
.collect(Collectors.toList()));
} else {
request.setOptType("2");
updateWeightData(request);
}
}
case "1" -> {
entity.setWeightDataList(
request.getWeightDataList().stream()
.map(
x ->
entityManager.getReference(
WeightDeviceDataEntity.class, x))
.collect(Collectors.toList()));
}
case "2" -> {
entity.setWeightDataList(
entity.getWeightDataList().stream()
.filter(x -> !request.getWeightDataList().contains(x.getId()))
.collect(Collectors.toList()));
}
}
this.repository.save(entity);
return getById(entity.getId());
@@ -241,7 +182,7 @@ public class PurchaseOrderService
.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,
select round(coalesce(sum(w.sz), 0), 2) as receivedAmount, coalesce(count(w.id),0) as totalCarCount, round(coalesce(min(p.amount),0) - coalesce(sum(w.sz),0),2) 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
@@ -262,15 +203,37 @@ public class PurchaseOrderService
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();
OrganizationConfigEntity currentOrgConfig = organizationConfigService.getCurrentOrgConfig();
return "CG" + singleResult;
switch (currentOrgConfig.getPurchaseOrderNoRule()) {
case "1" -> {
return sequenceService.genSeq(
"purchaseOrderNo." + Ctx.currentUser().getOrganizationId(),
currentOrgConfig.getPurchaseOrderNoPrefix(),
currentOrgConfig.getPurchaseOrderNoAutoIncrLength(),
currentOrgConfig.getPurchaseOrderNoStart(),
currentOrgConfig.getPurchaseOrderNoStep());
}
case "2" -> {
return sequenceService.genSeq(
"purchaseOrderNo."
+ Ctx.currentUser().getOrganizationId()
+ ObjectUtils.defaultIfNull(dto.getPurchaseDate(), LocalDate.now())
.format(DateTimeFormatter.ofPattern("yyyyMMdd")),
currentOrgConfig.getPurchaseOrderNoPrefix(),
currentOrgConfig.getPurchaseOrderNoAutoIncrLength(),
currentOrgConfig.getPurchaseOrderNoStart(),
currentOrgConfig.getPurchaseOrderNoStep());
}
case "3" -> {
return String.format(
"%s%s",
currentOrgConfig.getPurchaseOrderNoPrefix(),
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
}
default -> {
return "";
}
}
}
}

View File

@@ -19,6 +19,22 @@ public class SequenceService {
createSequence(name, start, 1);
}
public String genSeq(String name, String prefix, Integer length, Integer start, Integer step) {
createSequence(name, start, step);
Long nextVal = nextVal(name);
//检查长度
if (length < nextVal.toString().length()) {
throw new RuntimeException("sequence length is not enough: " + length + " < " + nextVal.toString().length());
}
return prefix + String.format("%0" + length + "d", nextVal);
}
public void createSequence(String name, Integer start, Integer step) {
if (start <= 1){

View File

@@ -1738,6 +1738,29 @@
}
]
},
{
"code": "purchaseOrder.genRule",
"name": "采购订单编号生成规则",
"item": [
{
"code": "0",
"name": "手动填写"
},
{
"code": "1",
"name": "全局递增"
},
{
"code": "2",
"name": "年月日+递增"
},
{
"code": "3",
"name": "年月日时分秒"
}
]
},
{
"code": "netDisk.entryType",
"name": "网盘文件类型",

View File

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