mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
Merge branch 'main' of ssh://192.168.1.205:9922/cf_devdept2/cf_imes_server
This commit is contained in:
-29
@@ -1,29 +0,0 @@
|
||||
package com.cf.imes.module.manage.api.pack.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 生产单包裹信息")
|
||||
@Data
|
||||
public class PrintOrderPackReqVO {
|
||||
|
||||
|
||||
|
||||
@Schema(description = "生产单id")
|
||||
private Long orderId;
|
||||
|
||||
|
||||
@Schema(description = "包裹编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String packNo;
|
||||
|
||||
|
||||
@Schema(description = "包裹ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long packId;
|
||||
|
||||
|
||||
@Schema(description = "包裹数量", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long packNum;
|
||||
|
||||
|
||||
}
|
||||
+3
@@ -27,6 +27,9 @@ public class OtherPackReqVO {
|
||||
private String name;
|
||||
|
||||
|
||||
@Schema(description = "配件数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "9822")
|
||||
private Double num;
|
||||
|
||||
@Schema(description = "包裹编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9822")
|
||||
private String packNo;
|
||||
|
||||
|
||||
+3
-1
@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@TableName("order_item")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@@ -44,7 +46,7 @@ public class OrderItemDO {
|
||||
private Long packageId;
|
||||
|
||||
// 部件数量
|
||||
private Float num;
|
||||
private Double num;
|
||||
|
||||
// 组织 ID
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.cf.imes.module.manage.enums;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum OrderPackStatusEnums {
|
||||
|
||||
|
||||
UNPACKAGED(0,"未打包"),
|
||||
INPACKAGING(1, "打包中"),
|
||||
PACKAGED(1, "打包完成");
|
||||
private Integer status;
|
||||
private String description;
|
||||
|
||||
|
||||
public boolean equals(Integer status) {
|
||||
return this.status .equals(status) ;
|
||||
}
|
||||
|
||||
public boolean equals(OrderPackStatusEnums enableStatusEnum) {
|
||||
return enableStatusEnum != null && enableStatusEnum.status .equals(this.getStatus()) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+2
-8
@@ -565,7 +565,7 @@ public class PackServiceImpl implements PackService {
|
||||
orderItemDO.setOrderId(reqVO.getOrderId());
|
||||
orderItemDO.setPartsId(orderParts.getId());
|
||||
orderItemDO.setPackageId(orderPackageDO.getId());
|
||||
orderItemDO.setNum(Float.valueOf(1));
|
||||
orderItemDO.setNum(reqVO.getNum());
|
||||
|
||||
|
||||
// 在生产单明细表中新增数据
|
||||
@@ -591,12 +591,6 @@ public class PackServiceImpl implements PackService {
|
||||
throw exception(THE_CURRENT_PACKAGE_TYPE_IS_INCORRECT);
|
||||
}
|
||||
|
||||
// 判断配件名称是否重复
|
||||
OrderPartsNDO orderPartsNDO = orderPartsMapper.selectOneParts(reqVO.getName(),getUserOrganId());
|
||||
|
||||
if (orderPartsNDO != null) {
|
||||
throw exception(THE_ACCESSORY_NAME_CANNOT_BE_DUPLICATED);
|
||||
}
|
||||
|
||||
// 配件表新增数据
|
||||
OrderPartsNDO orderParts = BeanUtils.toBean(reqVO, OrderPartsNDO.class);
|
||||
@@ -609,7 +603,7 @@ public class PackServiceImpl implements PackService {
|
||||
orderItemDO.setOrderId(reqVO.getOrderId());
|
||||
orderItemDO.setPartsId(orderParts.getId());
|
||||
orderItemDO.setPackageId(orderPackageDO.getId());
|
||||
orderItemDO.setNum(Float.valueOf(1));
|
||||
orderItemDO.setNum(reqVO.getNum());
|
||||
|
||||
// 在生产单明细表中新增数据
|
||||
orderItemMapper.insert(orderItemDO);
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.cf.imes.module.manage.util;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class MinuteCounter {
|
||||
private static final int MASK = 0x7FFFFFFF;
|
||||
private final AtomicInteger atom;
|
||||
|
||||
public MinuteCounter() {
|
||||
atom = new AtomicInteger(0);
|
||||
}
|
||||
|
||||
public final int incrementAndGet() {
|
||||
return atom.incrementAndGet() & MASK;
|
||||
}
|
||||
|
||||
public int get() {
|
||||
return atom.get() & MASK;
|
||||
}
|
||||
|
||||
public void set(int newValue) {
|
||||
atom.set(newValue & MASK);
|
||||
}
|
||||
|
||||
}
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
package com.cf.imes.module.manage.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @ClassName: SnowflakeIdWorker3rd
|
||||
* @Description:snowflake算法改进
|
||||
* @author: yonnie
|
||||
* @date: 2024/06/18 14:10:47
|
||||
* @version V1.0
|
||||
*
|
||||
* 将产生的Id类型更改为Integer 32bit <br>
|
||||
* 把时间戳的单位改为分钟,使用25bit的时间戳
|
||||
* 7bit作为自增值即 2^7 = 128
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SnowflakeIdWorker3rd {
|
||||
/** 初始时间 (2024-01-01: 1704038400) */
|
||||
// private final int twepoch = 28400640;// 1704038400000L/1000/60;
|
||||
private final int twepoch = 1704038400;
|
||||
/** 序列在id中占位数 */
|
||||
private final long sequenceBits = 7L;
|
||||
/** 时间截向左移7bit */
|
||||
private final long timestampLeftShift = sequenceBits;
|
||||
/** 生成序列的MASK (0x7F) */
|
||||
private final int sequenceMask = -1 ^ (-1 << sequenceBits);
|
||||
/** 分钟内序 (0~127) */
|
||||
private int sequence = 0;
|
||||
private int laterSequence = 0;
|
||||
/** 上次生成ID的时间戳 */
|
||||
private int lastTimestamp = -1;
|
||||
private final MinuteCounter counter = new MinuteCounter();
|
||||
/** 预支时间标志 */
|
||||
boolean isAdvance = false;
|
||||
|
||||
// ==============================Constructors=====================================
|
||||
|
||||
public SnowflakeIdWorker3rd() {
|
||||
}
|
||||
|
||||
// ==============================Test=============================================
|
||||
|
||||
/** 测试 */
|
||||
public static void main(String[] args) {
|
||||
SnowflakeIdWorker3rd idWorker = new SnowflakeIdWorker3rd();
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
long id = idWorker.nextId();
|
||||
System.out.println(i + ": " + id + " " + "2406" + Long.toString(id).substring(2));
|
||||
}
|
||||
// long id = idWorker.nextId();
|
||||
// System.out.println(id);
|
||||
}
|
||||
|
||||
// ==============================Methods==========================================
|
||||
/**
|
||||
* 获取当前年月
|
||||
* @return null
|
||||
*/
|
||||
public static int obtainingTime() {
|
||||
LocalDate now = LocalDate.now();
|
||||
int year = now.getYear();
|
||||
String year_last_two_digits = String.valueOf(year).substring(2);
|
||||
int month = now.getMonthValue();
|
||||
String formatted_date = year_last_two_digits + String.format("%02d", month);
|
||||
return Integer.parseInt(formatted_date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得下一个ID (该方法是线程安全)
|
||||
*
|
||||
* @return SnowflakeId
|
||||
*/
|
||||
public synchronized int nextId() {
|
||||
int timestamp = timeGen();
|
||||
// 如果当前时间小于上一次ID生成的时间戳,说明系统时钟修改过
|
||||
if (timestamp < lastTimestamp) {
|
||||
throw new RuntimeException(String.format(
|
||||
"Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
|
||||
}
|
||||
|
||||
if (timestamp > counter.get()) {
|
||||
counter.set(timestamp);
|
||||
isAdvance = false;
|
||||
}
|
||||
|
||||
// 如果是同时间生成的,则进行分钟内序列
|
||||
if (lastTimestamp == timestamp || isAdvance) {
|
||||
if (!isAdvance) {
|
||||
sequence = (sequence + 1) & sequenceMask;
|
||||
}
|
||||
|
||||
// 分钟内自增列溢出
|
||||
if (sequence == 0) {
|
||||
// 预支下一分获得新的时间戳
|
||||
isAdvance = true;
|
||||
int laterTimestamp = counter.get();
|
||||
if (laterSequence == 0) {
|
||||
laterTimestamp = counter.incrementAndGet();
|
||||
}
|
||||
int nextId = ((laterTimestamp - twepoch) << timestampLeftShift) | laterSequence;
|
||||
laterSequence = (laterSequence + 1) & sequenceMask;
|
||||
return nextId;
|
||||
}
|
||||
} else { // 时间戳改变,分钟内序列置0
|
||||
sequence = 0;
|
||||
laterSequence = 0;
|
||||
}
|
||||
// 上次生成ID的时间截
|
||||
lastTimestamp = timestamp;
|
||||
// 移位并或运算拼成32位的ID
|
||||
return ((timestamp - twepoch) << timestampLeftShift) | sequence;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回以分钟为单位的当前时
|
||||
*
|
||||
* @return 当前时间(分钟)
|
||||
*/
|
||||
protected int timeGen() {
|
||||
// String timestamp = String.valueOf(System.currentTimeMillis() / 1000 / 60);
|
||||
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
|
||||
return Integer.valueOf(timestamp);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user