diff --git a/cf-gateway/src/main/resources/bootstrap.yaml b/cf-gateway/src/main/resources/bootstrap.yaml
index 3eed7be68..35745b83b 100644
--- a/cf-gateway/src/main/resources/bootstrap.yaml
+++ b/cf-gateway/src/main/resources/bootstrap.yaml
@@ -7,6 +7,11 @@ spring:
server:
port: 48080
+ # 开启Gzip压缩,默认只压缩超过2048字节的数据
+ compression:
+ enabled: true
+ min-response-size: 2048
+ mime-types: application/json
# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件
logging:
diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/pack/vo/OtherPackReqVO.java b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/pack/vo/OtherPackReqVO.java
index 8b9fc8dfd..af4bf291e 100644
--- a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/pack/vo/OtherPackReqVO.java
+++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/pack/vo/OtherPackReqVO.java
@@ -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;
diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/dal/dataobject/query/OrderItemDO.java b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/dal/dataobject/query/OrderItemDO.java
index c82b4bab1..7f74629d2 100644
--- a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/dal/dataobject/query/OrderItemDO.java
+++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/dal/dataobject/query/OrderItemDO.java
@@ -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)
diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/enums/OrderPackStatusEnums.java b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/enums/OrderPackStatusEnums.java
new file mode 100644
index 000000000..2087ee2a6
--- /dev/null
+++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/enums/OrderPackStatusEnums.java
@@ -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()) ;
+ }
+
+
+
+}
diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/service/pack/PackServiceImpl.java b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/service/pack/PackServiceImpl.java
index 11059f599..d8fc46c8e 100644
--- a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/service/pack/PackServiceImpl.java
+++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/service/pack/PackServiceImpl.java
@@ -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);
diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/util/MinuteCounter.java b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/util/MinuteCounter.java
new file mode 100644
index 000000000..34f949136
--- /dev/null
+++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/util/MinuteCounter.java
@@ -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);
+ }
+
+}
\ No newline at end of file
diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/util/SnowflakeIdWorker3rd.java b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/util/SnowflakeIdWorker3rd.java
new file mode 100644
index 000000000..83977afa2
--- /dev/null
+++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/util/SnowflakeIdWorker3rd.java
@@ -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
+ * 把时间戳的单位改为分钟,使用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);
+ }
+
+}
diff --git a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java
index df0c49c1f..581fea2c0 100644
--- a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java
+++ b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java
@@ -266,6 +266,7 @@ public interface ErrorCodeConstants {
ErrorCode THE_CURRENT_PACKAGE_HAS_AN_UNSEALED_PACKAGE = new ErrorCode(1_002_038_666, "当前包裹还有未封包包裹");
ErrorCode THE_CURRENT_PACKAGE_TYPE_IS_INCORRECT = new ErrorCode(1_002_038_777, "当前包裹类型错误");
ErrorCode FAILED_TO_MODIFY_THE_STATUS_OF_THE_CURRENT_PRODUCTION_ORDER = new ErrorCode(1_002_038_778, "修改当前生产单的工序状态和生产单的状态失败");
+ ErrorCode NO_OPTIMIZATION_INFORMATION_AVAILABLE = new ErrorCode(1_002_038_779, "当前订单无优化信息");
//=========== 应用信息 1-002-037-000 ============
@@ -278,4 +279,8 @@ public interface ErrorCodeConstants {
ErrorCode REMAIN_PLATE_STATUS_NO_USED = new ErrorCode(1_002_038_002, "余料板未使用");
ErrorCode REMAIN_PLATE_USR_TYPE = new ErrorCode(1_002_038_003, "余料板使用类型为不可核销类型");
ErrorCode REMAIN_PLATE_ID_NOT_EXISTS = new ErrorCode(1_002_038_004, "未选中余料板,请选择余料板");
+
+
+ //=========== 用户的系统配置 1-002-039-000 ============
+ ErrorCode CURRENTLY_NO_CONFIGURATION_AVAILABLE = new ErrorCode(1_002_039_001, "当前没有配置信息,请前往设置配置");
}
diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/datasource/DataSourceApiImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/datasource/DataSourceApiImpl.java
index 068a4273b..b8c8635e8 100644
--- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/datasource/DataSourceApiImpl.java
+++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/datasource/DataSourceApiImpl.java
@@ -24,6 +24,6 @@ public class DataSourceApiImpl implements DataSourceApi {
if(Objects.isNull(dataSourceDO)) {
throw exception(new ErrorCode(2133,"数据源不存在"));
}
- return CommonResult.success(dataSourceDO.getSqlStr()) ;
+ return null;
}
}
diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/setting/SettingController.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/setting/SettingController.java
new file mode 100644
index 000000000..c0d5eefd8
--- /dev/null
+++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/setting/SettingController.java
@@ -0,0 +1,67 @@
+package com.cf.imes.module.system.controller.admin.setting;
+
+
+import com.cf.imes.framework.common.pojo.CommonResult;
+import com.cf.imes.module.system.controller.admin.datasource.vo.DataSourceFiledReqVO;
+import com.cf.imes.module.system.controller.admin.setting.vo.PackageConfigReqVO;
+import com.cf.imes.module.system.service.setting.SettingService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+
+
+import static com.cf.imes.framework.common.pojo.CommonResult.success;
+
+@Tag(name = "管理后台 - 系统配置")
+@RestController
+@RequestMapping("/system/setting")
+@Validated
+public class SettingController {
+
+
+ @Resource
+ private SettingService settingService;
+
+
+
+ @PutMapping("/insert")
+ @Operation(summary = "新增系统配置")
+ //@PreAuthorize("@ss.hasPermission('system:data-source:query')")
+ public CommonResult insertSetting( @RequestBody PackageConfigReqVO reqVO ) {
+
+ return success(settingService.insertSetting(reqVO));
+
+
+ }
+
+
+
+ @PostMapping("/update")
+ @Operation(summary = "更新系统配置")
+ //@PreAuthorize("@ss.hasPermission('system:data-source:query')")
+ public CommonResult updateSetting( @RequestBody PackageConfigReqVO reqVO ) {
+
+ return success(settingService.updateSetting(reqVO));
+
+
+ }
+
+
+ @GetMapping("/select")
+ @Operation(summary = "查看当前用户的配置信息")
+ @Parameter(name = "type", description = "配置类型", required = true)
+ public CommonResult selectSetting( @RequestParam("type") Integer type ) {
+
+ return success(settingService.selectSetting(type));
+
+
+ }
+
+
+
+}
diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/setting/SettingMapper.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/setting/SettingMapper.java
new file mode 100644
index 000000000..93fb6eeb2
--- /dev/null
+++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/setting/SettingMapper.java
@@ -0,0 +1,26 @@
+package com.cf.imes.module.system.dal.mysql.setting;
+
+import com.cf.imes.framework.common.pojo.PageResult;
+import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
+import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
+import com.cf.imes.module.system.controller.admin.machine.vo.MachinePageReqVO;
+import com.cf.imes.module.system.dal.dataobject.machinetemplate.MachineTemplateDO;
+import com.cf.imes.module.system.dal.dataobject.setting.PackageConfigDO;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.Collection;
+
+
+@Mapper
+public interface SettingMapper extends BaseMapperX {
+
+
+
+ default PackageConfigDO selectSetting(Integer type, Long id, Long organId) {
+ return selectOne( new LambdaQueryWrapperX()
+ .eqIfPresent(PackageConfigDO::getOrganId,organId)
+ .eqIfPresent(PackageConfigDO::getUserId,id)
+ .eqIfPresent(PackageConfigDO::getType,type));
+ }
+
+}
diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/setting/SettingService.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/setting/SettingService.java
new file mode 100644
index 000000000..d5cdb5ee8
--- /dev/null
+++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/setting/SettingService.java
@@ -0,0 +1,16 @@
+package com.cf.imes.module.system.service.setting;
+
+
+import com.cf.imes.module.system.controller.admin.setting.vo.PackageConfigReqVO;
+import org.springframework.stereotype.Service;
+
+public interface SettingService {
+
+
+
+ Long insertSetting(PackageConfigReqVO reqVO);
+
+ Long updateSetting(PackageConfigReqVO reqVO);
+
+ PackageConfigReqVO selectSetting(Integer type);
+}
diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/setting/SettingServiceImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/setting/SettingServiceImpl.java
new file mode 100644
index 000000000..5df8fa98b
--- /dev/null
+++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/setting/SettingServiceImpl.java
@@ -0,0 +1,83 @@
+package com.cf.imes.module.system.service.setting;
+
+
+import com.cf.imes.framework.common.util.json.JsonUtils;
+import com.cf.imes.framework.common.util.object.BeanUtils;
+import com.cf.imes.framework.security.core.LoginUser;
+import com.cf.imes.module.system.controller.admin.setting.vo.PackageConfigReqVO;
+import com.cf.imes.module.system.dal.dataobject.setting.PackageConfigDO;
+import com.cf.imes.module.system.dal.mysql.setting.SettingMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+
+import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
+import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
+
+
+@Service
+@Validated
+public class SettingServiceImpl implements SettingService{
+
+
+ @Resource
+ private SettingMapper settingMapper;
+
+
+ @Override
+ public Long insertSetting(PackageConfigReqVO reqVO) {
+
+ LoginUser loginUser = getLoginUser();
+ PackageConfigDO packageConfigDO = PackageConfigDO.builder()
+ .userId(loginUser.getId())
+ .organId(loginUser.getOrganId())
+ .setting(JsonUtils.zipString(reqVO.getSetting().toJSONString()))
+ .type(reqVO.getType())
+ .build();
+
+ settingMapper.insert(packageConfigDO);
+
+
+ return packageConfigDO.getId();
+
+ }
+
+
+ @Override
+ public Long updateSetting(PackageConfigReqVO reqVO) {
+
+ // 更新
+ PackageConfigDO packageConfigDO = settingMapper.selectById(reqVO.getId());
+ if (packageConfigDO == null) {
+ throw exception(CURRENTLY_NO_CONFIGURATION_AVAILABLE);
+ }
+ if(reqVO.getSetting() != null) {
+ packageConfigDO.setSetting(JsonUtils.zipString(reqVO.getSetting().toJSONString()));
+ }
+ settingMapper.updateById(packageConfigDO);
+
+ return packageConfigDO.getId();
+ }
+
+
+
+ @Override
+ public PackageConfigReqVO selectSetting(Integer type) {
+
+ LoginUser loginUser = getLoginUser();
+
+ PackageConfigDO packageConfigDO = settingMapper.selectSetting(type, loginUser.getId(), loginUser.getOrganId());
+
+ if (packageConfigDO == null) {
+ throw exception(CURRENTLY_NO_CONFIGURATION_AVAILABLE);
+ }
+
+ packageConfigDO.setSetting(JsonUtils.unzipString(packageConfigDO.getSetting()));
+
+ return BeanUtils.toBean(packageConfigDO,PackageConfigReqVO.class);
+ }
+
+
+}