feat: 添加功能

This commit is contained in:
曹鹏飞 2025-08-01 14:20:53 +08:00
parent cb741c328f
commit 8a0b9205e3
12 changed files with 308 additions and 31 deletions

View File

@ -7,6 +7,7 @@ import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.DigestUtil; import cn.hutool.crypto.digest.DigestUtil;
import cn.hutool.json.JSONUtil;
import cn.idev.excel.EasyExcel; import cn.idev.excel.EasyExcel;
import cn.idev.excel.enums.CellDataTypeEnum; import cn.idev.excel.enums.CellDataTypeEnum;
import cn.idev.excel.metadata.data.ImageData; import cn.idev.excel.metadata.data.ImageData;
@ -531,32 +532,38 @@ public class StructuralPackageOrderController extends BaseController {
* @param type 类型 * @param type 类型
*/ */
private void saveMaterialQrCodeScanRecord(List<String> content, Integer type) { private void saveMaterialQrCodeScanRecord(List<String> content, Integer type) {
packageMaterialScanRecordRepository.saveAll(content.stream().map(qrCode -> { try {
List<String> qrContents = StrUtil.split(qrCode, "^"); log.info(StrUtil.format("保存物料二维码扫描记录,类型:{},二维码列表:{}", type, JSONUtil.toJsonStr(content)));
if (CollectionUtil.isEmpty(qrContents)) { List<PackageMaterialScanRecord> records = packageMaterialScanRecordRepository.saveAll(content.stream().map(qrCode -> {
qrContents = StrUtil.split(qrContents.get(1), "_"); List<String> qrContents = StrUtil.split(qrCode, "^");
return new PackageMaterialScanRecord() if (CollectionUtil.isEmpty(qrContents)) {
.setUniqNo(qrCode) qrContents = StrUtil.split(qrContents.get(1), "_");
.setContent(qrCode) return new PackageMaterialScanRecord()
.setMaterialNo(qrContents.get(0)) .setUniqNo(qrCode)
.setTrayNo(qrContents.get(1)) .setContent(qrCode)
.setType(type) .setMaterialNo(qrContents.get(0))
.setNum(qrContents.get(2)) .setTrayNo(qrContents.get(1))
.setCreateBy(UserUtil.getUserName()) .setType(type)
.setCreateTime(Instant.now()); .setNum(qrContents.get(2))
} else { .setCreateBy(UserUtil.getUserName())
List<String> datas = StrUtil.split(qrContents.get(1), "_"); .setCreateTime(Instant.now());
return new PackageMaterialScanRecord() } else {
.setUniqNo(qrContents.get(0)) List<String> datas = StrUtil.split(qrContents.get(1), "_");
.setContent(qrCode) return new PackageMaterialScanRecord()
.setMaterialNo(datas.get(0)) .setUniqNo(qrContents.get(0))
.setTrayNo(datas.get(1)) .setContent(qrCode)
.setType(type) .setMaterialNo(datas.get(0))
.setNum(datas.get(2)) .setTrayNo(datas.get(1))
.setCreateBy(UserUtil.getUserName()) .setType(type)
.setCreateTime(Instant.now()); .setNum(datas.get(2))
} .setCreateBy(UserUtil.getUserName())
}).filter(Objects::nonNull).toList()); .setCreateTime(Instant.now());
}
}).filter(Objects::nonNull).toList());
log.info("保存物料二维码扫描记录成功,数据:{}", JSONUtil.toJsonStr(records));
} catch (Exception ex) {
log.error("保存物料二维码扫描记录失败", ex);
}
} }
/** /**

View File

@ -5,4 +5,4 @@ import org.springframework.data.mongodb.repository.MongoRepository;
public interface PackageMaterialScanRecordRepository extends MongoRepository<PackageMaterialScanRecord, String> { public interface PackageMaterialScanRecordRepository extends MongoRepository<PackageMaterialScanRecord, String> {
} }

View File

@ -33,7 +33,7 @@ public class SaTokenConfigure {
.setAuth(obj -> { .setAuth(obj -> {
// 登录校验 -- 拦截所有路由 // 登录校验 -- 拦截所有路由
SaRouter.match("/**") SaRouter.match("/**")
.notMatch("/auth/**", "/actuator/**") .notMatch("/auth/**","/srm-receive/**", "**/actuator/**")
.check(r -> { .check(r -> {
String currentUrl = SaHolder.getRequest().getRequestPath(); String currentUrl = SaHolder.getRequest().getRequestPath();
log.info("当前鉴权地址:{}", currentUrl); log.info("当前鉴权地址:{}", currentUrl);

View File

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.nflg</groupId>
<artifactId>nflg-wms</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>nflg-wms-srm-receive</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>服务-SRM订单接收</name>
<description>SRM订单接收服务</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.nflg</groupId>
<artifactId>nflg-wms-common</artifactId>
</dependency>
<dependency>
<groupId>com.nflg</groupId>
<artifactId>nflg-wms-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.github.loki4j</groupId>
<artifactId>loki-logback-appender</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<excludeGroupIds>${project.groupId}</excludeGroupIds>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.nflg.wms.srm.receive.SrmReceiveApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>${project.groupId}:*</include>
</includes>
</artifactSet>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,18 @@
package com.nflg.wms.srm.receive;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@Slf4j
@ComponentScan(basePackages = {"com.nflg.wms.srm.receive","com.nflg.wms.starter","com.nflg.wms.repository"})
@SpringBootApplication
public class SrmReceiveApplication {
public static void main(String[] args) {
SpringApplication.run(SrmReceiveApplication.class, args);
log.info("服务已启动");
}
}

View File

@ -0,0 +1,19 @@
package com.nflg.wms.srm.receive.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(3_000);
factory.setReadTimeout(10_000);
return new RestTemplate(factory);
}
}

View File

@ -1,4 +1,4 @@
package com.nflg.wms.admin.controller; package com.nflg.wms.srm.receive.controller;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
@ -10,7 +10,10 @@ import com.nflg.wms.repository.entity.WmsInTaskItem;
import com.nflg.wms.repository.entity.WmsSrmOrder; import com.nflg.wms.repository.entity.WmsSrmOrder;
import com.nflg.wms.repository.entity.WmsSrmOrderItem; import com.nflg.wms.repository.entity.WmsSrmOrderItem;
import com.nflg.wms.repository.entity.WmsSrmQualityInspection; import com.nflg.wms.repository.entity.WmsSrmQualityInspection;
import com.nflg.wms.repository.service.*; import com.nflg.wms.repository.service.IWmsInTaskService;
import com.nflg.wms.repository.service.IWmsSrmOrderItemService;
import com.nflg.wms.repository.service.IWmsSrmOrderService;
import com.nflg.wms.repository.service.IWmsSrmQualityInspectionService;
import com.nflg.wms.starter.BaseController; import com.nflg.wms.starter.BaseController;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -31,7 +34,7 @@ import java.util.Objects;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/api/NFSRM") @RequestMapping("/NFSRM")
public class SRMController extends BaseController { public class SRMController extends BaseController {
@Resource @Resource

View File

@ -0,0 +1,8 @@
logging:
level:
root: info
com:
nflg: debug
alibaba:
cloud:
nacos: debug

View File

@ -0,0 +1,26 @@
server:
port: 8104
servlet:
context-path: /api
spring:
main:
allow-bean-definition-overriding: true
application:
name: srm-receive
profiles:
active: sit
config:
import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true
cloud:
nacos:
config:
server-addr: ${nacos.server-addr:192.168.163.83:8848}
namespace: wms
group: ${spring.profiles.active}
discovery:
server-addr: ${nacos.server-addr:192.168.163.83:8848}
namespace: wms
group: ${spring.profiles.active}
logging:
level:
root: info

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 引入Spring Boot默认的基础配置 -->
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<Property name="logDir" value="./logs" />
<springProperty scope="context" name="appName" source="spring.application.name" defaultValue="srm-receive"/>
<springProperty scope="context" name="profile" source="spring.profiles.active" defaultValue="sit"/>
<define name="HOSTIP" class="com.nflg.wms.starter.definer.HostIpDefiner"/>
<!-- 控制台输出配置 -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%X{traceId}] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- 文件日志配置 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logDir}/nflg-wms-srm-receive.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 按天滚动日志并按大小拆分 -->
<fileNamePattern>${logDir}/%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- 单个日志文件最大大小 -->
<maxFileSize>10MB</maxFileSize>
<!-- 日志保留天数 -->
<maxHistory>7</maxHistory>
<!-- 所有日志文件的总大小上限 -->
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%X{traceId}] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
<http>
<url>http://192.168.163.83:3100/loki/api/v1/push</url>
</http>
<labels>
service_name = wms
app = ${appName}
profile = ${profile}
host = ${HOSTIP}
</labels>
<structuredMetadata>
level = %level
thread = %thread
class = %logger
</structuredMetadata>
<batch>
<staticLabels>true</staticLabels>
<maxItems>5</maxItems>
<timeoutMs>10000</timeoutMs>
</batch>
<message>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%X{traceId}] %-5level %logger{50} - %msg %ex</pattern>
</message>
</appender>
<logger name="com.alibaba.nacos" level="warn" additivity="false">
<!-- <appender-ref ref="FILE"/>-->
<appender-ref ref="LOKI"/>
</logger>
<!-- 默认配置 -->
<root level="DEBUG">
<appender-ref ref="CONSOLE"/>
<!-- <appender-ref ref="FILE"/>-->
<appender-ref ref="LOKI"/>
</root>
</configuration>

View File

@ -0,0 +1,13 @@
package com.nflg.wms.srm.receive;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class SrmReceiveApplicationTests {
@Test
void contextLoads() {
}
}

View File

@ -23,6 +23,7 @@
<module>nflg-wms-auth</module> <module>nflg-wms-auth</module>
<module>nflg-wms-file</module> <module>nflg-wms-file</module>
<module>nflg-wms-scheduled</module> <module>nflg-wms-scheduled</module>
<module>nflg-wms-srm-receive</module>
</modules> </modules>
<properties> <properties>
<java.version>17</java.version> <java.version>17</java.version>