一些优化

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.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.ldap.core.support.LdapContextSource;
import java.util.HashMap;
@ -24,6 +25,7 @@ public class LdapConfig {
private String password;
@Bean
@Lazy
public LdapContextSource ldapContextSource() {
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(ldapUrl);

View File

@ -20,6 +20,7 @@ public class PowerJobClientConfig {
private String password;
@Bean
@Lazy
public PowerJobClient initPowerJobClient() {
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.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@ -9,6 +10,7 @@ import org.springframework.web.client.RestTemplate;
public class RestTemplateConfig {
@Bean
@Lazy
public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
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.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import java.util.HashMap;
import java.util.Map;
@ -96,6 +97,7 @@ public class SAPConfig {
}
@Bean
@Lazy
public JCoRepository getJCoRepository() throws JCoException {
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.Configuration;
import org.springframework.context.annotation.Lazy;
import org.thymeleaf.ITemplateEngine;
import org.thymeleaf.spring6.SpringTemplateEngine;
import org.thymeleaf.templateresolver.ITemplateResolver;
@ -10,6 +11,7 @@ import org.thymeleaf.templateresolver.ITemplateResolver;
public class ThymeleafConfig {
@Bean
@Lazy
public ITemplateEngine templateEngine(ITemplateResolver templateResolver) {
SpringTemplateEngine engine = new SpringTemplateEngine();
engine.setTemplateResolver(templateResolver);

View File

@ -212,13 +212,15 @@ public class InCostCenterBackController extends BaseController {
.setId(IdUtil.getSnowflakeNextId())
.setTicketId(ticket.getId())
.setOrderItemId(item.getId())
.setLgpbe(StrUtil.join(",", it.getLgpbe()))
.setLgpbe(StrUtil.join(",", it.getBinNos()))
.setNum(BigDecimal.ZERO);
ticketItems.add(ti);
it.getQrCodes().forEach(qrCode -> {
MaterialQRCodeContentDTO qrCodeContent = NoUtil.getMaterialQRCodeContent(qrCode);
dtos.add(qrCodeContent);
String materialNo = qrCodeContent.getMaterialNo();
VUtil.trueThrowBusinessError(!StrUtil.equals(materialNo, item.getMatnr()))
.throwMessage("订单项与物料不符");
item.setLeft(item.getLeft().subtract(qrCodeContent.getNum()));
VUtil.trueThrowBusinessError(item.getLeft().compareTo(BigDecimal.ZERO) < 0)
.throwMessage("物料" + materialNo + "的入库数量超出申请数量");
@ -241,6 +243,14 @@ public class InCostCenterBackController extends BaseController {
inCostcenterBackItemService.updateBatchById(datas);
inMaterialScanRecordRespository.saveAll(records);
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()
.collect(Collectors.groupingBy(InMaterialScanRecord::getKey))
.values()
@ -262,7 +272,7 @@ public class InCostCenterBackController extends BaseController {
.setResbRspos(item.getRspos())
.setResbMatnr(item.getMatnr())
.setMaktx(item.getMaktx())
.setResbLgort(order.getLgort())
.setResbLgort(request.getLgort())
.setResbWerks(order.getWerks())
.setResbMeins(item.getMeins())
.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.setMatDoc(vo.getEMblnr());
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();
}

View File

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

View File

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

View File

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

View File

@ -5,6 +5,7 @@
<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="profile" source="spring.profiles.active" defaultValue="dev"/>
<define name="HOSTIP" class="com.nflg.wms.starter.definer.HostIpDefiner"/>
@ -51,7 +52,7 @@
<appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
<http>
<url>http://192.168.163.83:3100/loki/api/v1/push</url>
<url>${LOKI_URL}</url>
</http>
<labels>
service_name = wms

View File

@ -19,7 +19,7 @@ public class InCostcenterBackSubmitItemQO {
* 实际入库储位编号列表
*/
@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.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
@Configuration
@ConditionalOnProperty(name = "file.upload.type", havingValue = "oss")
@ -31,6 +32,7 @@ public class AliyunOSSConfig {
//private OSS ossClient;
@Bean(destroyMethod = "shutdown")
@Lazy
public OSS ossClient() {
log.info("初始化阿里云OSS服务");
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.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
@Slf4j
@Configuration
@ -31,6 +32,7 @@ public class MinIOConfig {
private MinioClient client;
@Bean
@Lazy
public MinioClient initMinioClient() throws Exception{
client= MinioClient.builder()
.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.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
@ -11,6 +12,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
public class RedisConfig {
@Bean
@Lazy
public RedisTemplate<String, Object> redisObjectTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory);
@ -27,6 +29,7 @@ public class RedisConfig {
}
@Bean
@Lazy
public RedisTemplate<String, String> redisStringTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<String, String> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory);