feat: init yueqian-erp based on xingyun
- Change groupId: com.lframework -> com.yueqian - Change artifactId: xingyun -> yueqian-erp - Rename modules: xingyun-* -> yueqian-erp-* - Update Java packages: com.lframework.xingyun -> com.yueqian.xingyun - Preserve external Jugg framework dependencies as com.lframework - Update README and documentation
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yueqian-erp</artifactId>
|
||||
<groupId>com.yueqian</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yueqian-erp-core</artifactId>
|
||||
<name>【${project.artifactId}】基础依赖</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.lframework</groupId>
|
||||
<artifactId>rabbitmq-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sun</groupId>
|
||||
<artifactId>tools</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.lframework</groupId>
|
||||
<artifactId>bpm-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sun</groupId>
|
||||
<artifactId>tools</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.yueqian.xingyun.core.components.timeline;
|
||||
|
||||
import com.lframework.starter.web.core.components.timeline.OrderTimeLineBizType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ReceiveOrderTimeLineBizType implements OrderTimeLineBizType {
|
||||
|
||||
@Override
|
||||
public Integer getCode() {
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yueqian.xingyun.core.queue;
|
||||
|
||||
import com.lframework.starter.mq.core.queue.QueueDefinition;
|
||||
import com.lframework.starter.mq.rabbitmq.queue.RabbitMQQueueDefinition;
|
||||
|
||||
public class MqConstants {
|
||||
|
||||
/**
|
||||
* 增加库存
|
||||
*/
|
||||
public static final QueueDefinition ADD_STOCK = new RabbitMQQueueDefinition(
|
||||
MqStringPool.ADD_STOCK_EXCHANGE);
|
||||
|
||||
/**
|
||||
* 扣减库存
|
||||
*/
|
||||
public static final QueueDefinition SUB_STOCK = new RabbitMQQueueDefinition(
|
||||
MqStringPool.SUB_STOCK_EXCHANGE);
|
||||
|
||||
/**
|
||||
* 审核通过订单
|
||||
*/
|
||||
public static final QueueDefinition APPROVE_PASS_ORDER = new RabbitMQQueueDefinition(
|
||||
MqStringPool.APPROVE_PASS_ORDER_EXCHANGE);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.yueqian.xingyun.core.queue;
|
||||
|
||||
public interface MqStringPool {
|
||||
|
||||
// 增加库存
|
||||
String ADD_STOCK_EXCHANGE = "add_stock.fanout";
|
||||
|
||||
// 扣减库存
|
||||
String SUB_STOCK_EXCHANGE = "sub_stock.fanout";
|
||||
|
||||
// 审核通过订单
|
||||
String APPROVE_PASS_ORDER_EXCHANGE = "approve_pass_order.fanout";
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.yueqian.xingyun.core.utils;
|
||||
|
||||
import com.lframework.starter.common.exceptions.impl.DefaultSysException;
|
||||
import com.lframework.starter.common.utils.CollectionUtil;
|
||||
import com.lframework.starter.common.utils.NumberUtil;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class SplitNumberUtil {
|
||||
|
||||
/**
|
||||
* 将 totalNum 按照权重指标分摊
|
||||
*
|
||||
* @param totalNum
|
||||
* @param datas key:唯一标识 value:权重指标
|
||||
* @param precision 精度
|
||||
* @return
|
||||
*/
|
||||
public static Map<Object, Number> split(Number totalNum, Map<Object, Number> datas,
|
||||
int precision) {
|
||||
if (CollectionUtil.isEmpty(datas)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (precision < 0) {
|
||||
throw new DefaultSysException("precision不允许小于0!");
|
||||
}
|
||||
if (!NumberUtil.isNumberPrecision(totalNum, precision)) {
|
||||
throw new DefaultSysException("totalNum的小数位数不允许大于 " + precision + "!");
|
||||
}
|
||||
|
||||
Number totalWeight = datas.values().stream().reduce(NumberUtil::add).orElse(BigDecimal.ZERO);
|
||||
Map<Object, Number> results = new HashMap<>(datas.size());
|
||||
Number remainNum = totalNum;
|
||||
|
||||
int index = 0;
|
||||
int dataSize = datas.size();
|
||||
for (Entry<Object, Number> entry : datas.entrySet()) {
|
||||
Object key = entry.getKey();
|
||||
Number val = entry.getValue();
|
||||
if (index == dataSize - 1) {
|
||||
// 最后一行
|
||||
results.put(key, remainNum);
|
||||
} else {
|
||||
Number curNum = NumberUtil.getNumber(NumberUtil.mul(totalNum,
|
||||
NumberUtil.equal(totalWeight, BigDecimal.ZERO) ? dataSize
|
||||
: NumberUtil.div(val, totalWeight)), precision);
|
||||
remainNum = NumberUtil.sub(remainNum, curNum);
|
||||
if (NumberUtil.lt(remainNum, BigDecimal.ZERO)) {
|
||||
curNum = NumberUtil.add(remainNum, curNum);
|
||||
remainNum = BigDecimal.ZERO;
|
||||
}
|
||||
results.put(key, curNum);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
config.stopBubbling=true
|
||||
lombok.equalsAndHashCode.callSuper=call
|
||||
Reference in New Issue
Block a user