一些优化

This commit is contained in:
曹鹏飞 2025-09-07 16:43:17 +08:00
parent 43454304dd
commit f3bc54aa94
14 changed files with 60 additions and 33 deletions

View File

@ -3,6 +3,7 @@ package com.nflg.wms.admin.config;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.ldap.core.support.LdapContextSource; import org.springframework.ldap.core.support.LdapContextSource;
import java.util.HashMap; import java.util.HashMap;
@ -24,6 +25,7 @@ public class LdapConfig {
private String password; private String password;
@Bean @Bean
@Lazy
public LdapContextSource ldapContextSource() { public LdapContextSource ldapContextSource() {
LdapContextSource contextSource = new LdapContextSource(); LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(ldapUrl); contextSource.setUrl(ldapUrl);

View File

@ -20,6 +20,7 @@ public class PowerJobClientConfig {
private String password; private String password;
@Bean @Bean
@Lazy
public PowerJobClient initPowerJobClient() { public PowerJobClient initPowerJobClient() {
return new PowerJobClient(serverAddress, appName, password); return new PowerJobClient(serverAddress, appName, password);
} }

View File

@ -2,6 +2,7 @@ package com.nflg.wms.admin.config;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.client.SimpleClientHttpRequestFactory; import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
@ -9,6 +10,7 @@ import org.springframework.web.client.RestTemplate;
public class RestTemplateConfig { public class RestTemplateConfig {
@Bean @Bean
@Lazy
public RestTemplate restTemplate() { public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(3_000); factory.setConnectTimeout(3_000);

View File

@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -96,6 +97,7 @@ public class SAPConfig {
} }
@Bean @Bean
@Lazy
public JCoRepository getJCoRepository() throws JCoException { public JCoRepository getJCoRepository() throws JCoException {
return jcoDestination().getRepository(); return jcoDestination().getRepository();
} }

View File

@ -2,6 +2,7 @@ package com.nflg.wms.admin.config;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.thymeleaf.ITemplateEngine; import org.thymeleaf.ITemplateEngine;
import org.thymeleaf.spring6.SpringTemplateEngine; import org.thymeleaf.spring6.SpringTemplateEngine;
import org.thymeleaf.templateresolver.ITemplateResolver; import org.thymeleaf.templateresolver.ITemplateResolver;
@ -10,6 +11,7 @@ import org.thymeleaf.templateresolver.ITemplateResolver;
public class ThymeleafConfig { public class ThymeleafConfig {
@Bean @Bean
@Lazy
public ITemplateEngine templateEngine(ITemplateResolver templateResolver) { public ITemplateEngine templateEngine(ITemplateResolver templateResolver) {
SpringTemplateEngine engine = new SpringTemplateEngine(); SpringTemplateEngine engine = new SpringTemplateEngine();
engine.setTemplateResolver(templateResolver); engine.setTemplateResolver(templateResolver);

View File

@ -212,13 +212,15 @@ public class InCostCenterBackController extends BaseController {
.setId(IdUtil.getSnowflakeNextId()) .setId(IdUtil.getSnowflakeNextId())
.setTicketId(ticket.getId()) .setTicketId(ticket.getId())
.setOrderItemId(item.getId()) .setOrderItemId(item.getId())
.setLgpbe(StrUtil.join(",", it.getLgpbe())) .setLgpbe(StrUtil.join(",", it.getBinNos()))
.setNum(BigDecimal.ZERO); .setNum(BigDecimal.ZERO);
ticketItems.add(ti); ticketItems.add(ti);
it.getQrCodes().forEach(qrCode -> { it.getQrCodes().forEach(qrCode -> {
MaterialQRCodeContentDTO qrCodeContent = NoUtil.getMaterialQRCodeContent(qrCode); MaterialQRCodeContentDTO qrCodeContent = NoUtil.getMaterialQRCodeContent(qrCode);
dtos.add(qrCodeContent); dtos.add(qrCodeContent);
String materialNo = qrCodeContent.getMaterialNo(); String materialNo = qrCodeContent.getMaterialNo();
VUtil.trueThrowBusinessError(!StrUtil.equals(materialNo, item.getMatnr()))
.throwMessage("订单项与物料不符");
item.setLeft(item.getLeft().subtract(qrCodeContent.getNum())); item.setLeft(item.getLeft().subtract(qrCodeContent.getNum()));
VUtil.trueThrowBusinessError(item.getLeft().compareTo(BigDecimal.ZERO) < 0) VUtil.trueThrowBusinessError(item.getLeft().compareTo(BigDecimal.ZERO) < 0)
.throwMessage("物料" + materialNo + "的入库数量超出申请数量"); .throwMessage("物料" + materialNo + "的入库数量超出申请数量");
@ -241,6 +243,14 @@ public class InCostCenterBackController extends BaseController {
inCostcenterBackItemService.updateBatchById(datas); inCostcenterBackItemService.updateBatchById(datas);
inMaterialScanRecordRespository.saveAll(records); inMaterialScanRecordRespository.saveAll(records);
inCostcenterBackTicketItemService.saveBatch(ticketItems); inCostcenterBackTicketItemService.saveBatch(ticketItems);
inCostcenterBackService.lambdaUpdate()
.set(WmsInCostcenterBack::getSapStatus, true)
.set(WmsInCostcenterBack::getSapError, "")
.set(WmsInCostcenterBack::getUpdateBy, UserUtil.getUserName())
.set(WmsInCostcenterBack::getUpdateTime, LocalDateTime.now())
.set(WmsInCostcenterBack::getState, datas.stream().map(WmsInCostcenterBackItem::getLeft).reduce(BigDecimal.ZERO, BigDecimal::add).compareTo(BigDecimal.ZERO) > 0 ? 1 : 2)
.eq(WmsInCostcenterBack::getId, order.getId())
.update();
inventoryService.in(records.stream() inventoryService.in(records.stream()
.collect(Collectors.groupingBy(InMaterialScanRecord::getKey)) .collect(Collectors.groupingBy(InMaterialScanRecord::getKey))
.values() .values()
@ -262,7 +272,7 @@ public class InCostCenterBackController extends BaseController {
.setResbRspos(item.getRspos()) .setResbRspos(item.getRspos())
.setResbMatnr(item.getMatnr()) .setResbMatnr(item.getMatnr())
.setMaktx(item.getMaktx()) .setMaktx(item.getMaktx())
.setResbLgort(order.getLgort()) .setResbLgort(request.getLgort())
.setResbWerks(order.getWerks()) .setResbWerks(order.getWerks())
.setResbMeins(item.getMeins()) .setResbMeins(item.getMeins())
.setErfmg(its.stream().map(MaterialQRCodeContentDTO::getNum).reduce(BigDecimal.ZERO, BigDecimal::add)) .setErfmg(its.stream().map(MaterialQRCodeContentDTO::getNum).reduce(BigDecimal.ZERO, BigDecimal::add))
@ -279,14 +289,6 @@ public class InCostCenterBackController extends BaseController {
ticket.setDocYear(vo.getEMJahr()); ticket.setDocYear(vo.getEMJahr());
ticket.setMatDoc(vo.getEMblnr()); ticket.setMatDoc(vo.getEMblnr());
inCostcenterBackTicketService.save(ticket); inCostcenterBackTicketService.save(ticket);
inCostcenterBackService.lambdaUpdate()
.set(WmsInCostcenterBack::getSapStatus, true)
.set(WmsInCostcenterBack::getSapError, "")
.set(WmsInCostcenterBack::getUpdateBy, UserUtil.getUserName())
.set(WmsInCostcenterBack::getUpdateTime, LocalDateTime.now())
.set(WmsInCostcenterBack::getState, datas.stream().map(WmsInCostcenterBackItem::getLeft).reduce(BigDecimal.ZERO, BigDecimal::add).compareTo(BigDecimal.ZERO) > 0 ? 1 : 2)
.eq(WmsInCostcenterBack::getId, order.getId())
.update();
return ApiResult.success(); return ApiResult.success();
} }

View File

@ -349,6 +349,8 @@ public class InProduceOrderController extends BaseController {
public ApiResult<List<InProduceOrderItemVO>> getOrderInfo(@Valid @RequestParam @NotBlank String no) { public ApiResult<List<InProduceOrderItemVO>> getOrderInfo(@Valid @RequestParam @NotBlank String no) {
WmsInProduceOrder order = produceOrderService.getByNo(no); WmsInProduceOrder order = produceOrderService.getByNo(no);
VUtil.trueThrowBusinessError(Objects.isNull(order)).throwMessage("订单不存在"); VUtil.trueThrowBusinessError(Objects.isNull(order)).throwMessage("订单不存在");
VUtil.trueThrowBusinessError(!Objects.equals(order.getState(), (short) 0))
.throwMessage("该订单非待收货状态");
List<InProduceOrderItemVO> list = produceOrderItemService.getVOByOrderId(order.getId()); List<InProduceOrderItemVO> list = produceOrderItemService.getVOByOrderId(order.getId());
if (order.getList()) { if (order.getList()) {
list = list.stream() list = list.stream()
@ -395,6 +397,7 @@ public class InProduceOrderController extends BaseController {
} }
List<String> materialNos = new ArrayList<>(); List<String> materialNos = new ArrayList<>();
List<InMaterialScanRecord> records = new ArrayList<>(); List<InMaterialScanRecord> records = new ArrayList<>();
List<Zwm00Mb107QO> input1 = new ArrayList<>();
list.forEach(it->{ list.forEach(it->{
BigDecimal num = BigDecimal.ZERO; BigDecimal num = BigDecimal.ZERO;
InProduceOrderReceiveMaterialQO materialQO = request.getItems().stream().filter(q -> StrUtil.equals(q.getMaterialNo(), it.getMaterialNo())).findFirst().orElse(null); InProduceOrderReceiveMaterialQO materialQO = request.getItems().stream().filter(q -> StrUtil.equals(q.getMaterialNo(), it.getMaterialNo())).findFirst().orElse(null);
@ -419,6 +422,18 @@ public class InProduceOrderController extends BaseController {
.setCreateBy(UserUtil.getUserName()) .setCreateBy(UserUtil.getUserName())
.setCreateTime(Instant.now()) .setCreateTime(Instant.now())
); );
Zwm00Mb107QO q = input1.stream().filter(ip -> StrUtil.equals(ip.getCHARG(), content.getBatchNo())).findFirst()
.orElseGet(() -> {
Zwm00Mb107QO qo = new Zwm00Mb107QO()
.setPWERK(it.getFactoryNo())
.setPSMNG(BigDecimal.ZERO)
.setAMEIN(it.getUnit())
.setLGORT(it.getWarehouseNo())
.setCHARG(content.getBatchNo());
input1.add(qo);
return qo;
});
q.setPSMNG(q.getPSMNG().add(content.getNum()));
} }
if (num.compareTo(it.getNum()) != 0) { if (num.compareTo(it.getNum()) != 0) {
materialNos.add(it.getMaterialNo()); materialNos.add(it.getMaterialNo());
@ -429,32 +444,22 @@ public class InProduceOrderController extends BaseController {
}); });
VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(materialNos)) VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(materialNos))
.throwMessage("以下物料的扫码数量与收货数量不一致:"+StrUtil.join(",", materialNos)); .throwMessage("以下物料的扫码数量与收货数量不一致:"+StrUtil.join(",", materialNos));
//同步入库信息到SAP inventoryService.in(input1.stream().map(it -> new InventoryDTO()
Zwm00Mb107DTO dto = sapService.zwm00_mb107(order.getOrderNo(), UserUtil.getUserName(), list.stream().map(it -> new Zwm00Mb107QO() .setMaterialNo(request.getItems().get(0).getMaterialNo())
.setPWERK(it.getFactoryNo()) .setNum(it.getPSMNG())
.setPSMNG(it.getNum()) .setFactoryNo(it.getPWERK())
.setAMEIN(it.getUnit()) .setWarehouseNo(it.getLGORT())
.setLGORT(it.getWarehouseNo()) .setBatchNumber(it.getCHARG())).toList()
.setCHARG(it.getBatchNo())).toList(), null
); );
produceOrderService.lambdaUpdate() inMaterialScanRecordRespository.saveAll(records);
.set(WmsInProduceOrder::getMjahr, dto.getE_MJAHR()) //同步入库信息到SAP
.set(WmsInProduceOrder::getMblnr, dto.getE_MBLNR()) Zwm00Mb107DTO dto = sapService.zwm00_mb107(order.getOrderNo(), UserUtil.getUserName(), input1, null);
.eq(WmsInProduceOrder::getId, order.getId()) order.setMblnr(dto.getE_MBLNR());
.update(); order.setMjahr(dto.getE_MJAHR());
order.setState((short)1); order.setState((short)1);
order.setUpdateBy(UserUtil.getUserName()); order.setUpdateBy(UserUtil.getUserName());
order.setUpdateTime(LocalDateTime.now()); order.setUpdateTime(LocalDateTime.now());
produceOrderService.updateById(order); produceOrderService.updateById(order);
inventoryService.in(list.stream().map(it-> new InventoryDTO()
.setMaterialNo(it.getMaterialNo())
.setNum(it.getNum())
.setFactoryNo(it.getFactoryNo())
.setWarehouseNo(it.getWarehouseNo())
.setBatchNumber(it.getBatchNo())).toList()
);
inMaterialScanRecordRespository.saveAll(records);
return ApiResult.success(); return ApiResult.success();
} }

View File

@ -119,6 +119,7 @@ public class SapService {
JCoFunction function = exec("ZWM00_MB107", parameters, tables); JCoFunction function = exec("ZWM00_MB107", parameters, tables);
JCoParameterList pl = function.getExportParameterList(); JCoParameterList pl = function.getExportParameterList();
log.info("E_MBLNR:{}", pl.getString("E_MBLNR"));
VUtil.trueThrowBusinessError(StrUtil.isBlank(pl.getString("E_MBLNR"))) VUtil.trueThrowBusinessError(StrUtil.isBlank(pl.getString("E_MBLNR")))
.throwMessage("SAP错误"); .throwMessage("SAP错误");
VUtil.trueHandle(StrUtil.isBlank(pl.getString("E_MBLNR"))).trueHandle(() -> { VUtil.trueHandle(StrUtil.isBlank(pl.getString("E_MBLNR"))).trueHandle(() -> {

View File

@ -1,4 +1,6 @@
logging: logging:
loki:
url: http://192.168.163.83:3100/loki/api/v1/push
level: level:
root: info root: info
com: com:

View File

@ -5,6 +5,7 @@
<Property name="logDir" value="./logs" /> <Property name="logDir" value="./logs" />
<springProperty scope="context" name="LOKI_URL" source="logging.loki.url" defaultValue=""/>
<springProperty scope="context" name="appName" source="spring.application.name" defaultValue="admin"/> <springProperty scope="context" name="appName" source="spring.application.name" defaultValue="admin"/>
<springProperty scope="context" name="profile" source="spring.profiles.active" defaultValue="dev"/> <springProperty scope="context" name="profile" source="spring.profiles.active" defaultValue="dev"/>
<define name="HOSTIP" class="com.nflg.wms.starter.definer.HostIpDefiner"/> <define name="HOSTIP" class="com.nflg.wms.starter.definer.HostIpDefiner"/>
@ -51,7 +52,7 @@
<appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender"> <appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
<http> <http>
<url>http://192.168.163.83:3100/loki/api/v1/push</url> <url>${LOKI_URL}</url>
</http> </http>
<labels> <labels>
service_name = wms service_name = wms

View File

@ -19,7 +19,7 @@ public class InCostcenterBackSubmitItemQO {
* 实际入库储位编号列表 * 实际入库储位编号列表
*/ */
@NotEmpty @NotEmpty
private List<String> lgpbe; private List<String> binNos;
/** /**
* 二维码列表 * 二维码列表

View File

@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
@Configuration @Configuration
@ConditionalOnProperty(name = "file.upload.type", havingValue = "oss") @ConditionalOnProperty(name = "file.upload.type", havingValue = "oss")
@ -31,6 +32,7 @@ public class AliyunOSSConfig {
//private OSS ossClient; //private OSS ossClient;
@Bean(destroyMethod = "shutdown") @Bean(destroyMethod = "shutdown")
@Lazy
public OSS ossClient() { public OSS ossClient() {
log.info("初始化阿里云OSS服务"); log.info("初始化阿里云OSS服务");
ClientConfiguration config = new ClientConfiguration(); ClientConfiguration config = new ClientConfiguration();

View File

@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
@Slf4j @Slf4j
@Configuration @Configuration
@ -31,6 +32,7 @@ public class MinIOConfig {
private MinioClient client; private MinioClient client;
@Bean @Bean
@Lazy
public MinioClient initMinioClient() throws Exception{ public MinioClient initMinioClient() throws Exception{
client= MinioClient.builder() client= MinioClient.builder()
.endpoint(endpoint) .endpoint(endpoint)

View File

@ -2,6 +2,7 @@ package com.nflg.wms.starter.config;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
@ -11,6 +12,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
public class RedisConfig { public class RedisConfig {
@Bean @Bean
@Lazy
public RedisTemplate<String, Object> redisObjectTemplate(RedisConnectionFactory redisConnectionFactory) { public RedisTemplate<String, Object> redisObjectTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>(); RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory); template.setConnectionFactory(redisConnectionFactory);
@ -27,6 +29,7 @@ public class RedisConfig {
} }
@Bean @Bean
@Lazy
public RedisTemplate<String, String> redisStringTemplate(RedisConnectionFactory redisConnectionFactory) { public RedisTemplate<String, String> redisStringTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<String, String> template = new RedisTemplate<>(); RedisTemplate<String, String> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory); template.setConnectionFactory(redisConnectionFactory);