From 3f332022ca04a0fa2806f424a1126cb9392a6153 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期五, 07 三月 2025 14:04:09 +0800
Subject: [PATCH] #新增 1. 质检上报功能 2. 新增流程配置功能
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/AsnOrderController.java | 18 +
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Purchase.java | 7
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ErpApiServiceImpl.java | 143 +++++++++++++++
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/PurchaseItem.java | 6
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/AsnOrderService.java | 3
rsf-server/src/main/resources/mapper/manager/PurchaseMapper.xml | 23 ++
rsf-server/src/main/java/com/vincent/rsf/server/api/entity/params/ErpInspectParams.java | 36 ++++
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/ScheduleJobs.java | 11 +
rsf-server/src/main/java/com/vincent/rsf/server/common/config/SysStockFlowProperties.java | 9 +
rsf-server/src/main/java/com/vincent/rsf/server/manager/mapper/PurchaseMapper.java | 6
rsf-server/src/main/java/com/vincent/rsf/server/api/service/ErpApiService.java | 3
rsf-server/src/main/java/com/vincent/rsf/server/api/entity/params/ErpInspectItem.java | 38 ++++
rsf-server/src/main/java/com/vincent/rsf/server/api/config/RestTemplateConfig.java | 22 ++
rsf-server/src/main/java/com/vincent/rsf/server/api/entity/dto/PoItemsDto.java | 43 ++++
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderServiceImpl.java | 46 +++++
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/AsnOrder.java | 6
rsf-common/src/main/java/com/vincent/rsf/common/domain/CommonReponse.java | 31 +++
rsf-server/src/main/java/com/vincent/rsf/server/api/config/RemotesInfoProperties.java | 46 +++++
rsf-server/src/main/resources/application-dev.yml | 22 ++
19 files changed, 507 insertions(+), 12 deletions(-)
diff --git a/rsf-common/src/main/java/com/vincent/rsf/common/domain/CommonReponse.java b/rsf-common/src/main/java/com/vincent/rsf/common/domain/CommonReponse.java
new file mode 100644
index 0000000..c4cacb9
--- /dev/null
+++ b/rsf-common/src/main/java/com/vincent/rsf/common/domain/CommonReponse.java
@@ -0,0 +1,31 @@
+package com.vincent.rsf.common.domain;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+import java.util.Map;
+
+/***
+ * 涓嬪彂浠诲姟鍝嶅簲Bean
+ */
+@Data
+@Accessors(chain = true)
+public class CommonReponse implements Serializable {
+
+ /***
+ * 鍝嶅簲鐘舵�佺爜銆�
+ * 飦�0锛氳〃绀烘帴鍙h姹傛垚鍔熴��
+ * 鍏朵粬鍊硷細琛ㄧず鎺ュ彛璇锋眰澶辫触锛岃缁嗕俊鎭鍙傝�冮敊璇爜銆�
+ */
+ private Integer code;
+ /**
+ *杩斿洖淇℃伅璇存槑銆�
+ * 飦垚鍔燂細"success"銆�
+ * 飦叾浠栵細璇︾粏鎻忚堪銆�
+ * */
+ private String msg;
+ /**
+ *杩斿洖鐨勫搷搴旀暟鎹粨鏋勩��
+ * */
+ private Map<String, Object> data;
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/config/RemotesInfoProperties.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/config/RemotesInfoProperties.java
new file mode 100644
index 0000000..1d07957
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/config/RemotesInfoProperties.java
@@ -0,0 +1,46 @@
+package com.vincent.rsf.server.api.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author Ryan
+ * @version 1.0
+ * @title RemotesInfoProperties
+ * @description
+ * @create 2025/3/7 09:48
+ */
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "platform.erp")
+public class RemotesInfoProperties {
+
+ /**
+ * 鎺ュ彛host
+ */
+ private String host;
+ /**
+ * 绔彛鍙�
+ */
+ private String port;
+
+ /**
+ * 鎺ュ彛閾炬帴鍓嶇紑
+ */
+ private String prePath;
+
+ @Data
+ @Configuration
+ @ConfigurationProperties(prefix = "platform.erp.apiInfo")
+ public class ApiInfo {
+ /**
+ * 涓�閿笂鎶ヨ川妫�鎺ュ彛
+ */
+ private String notifyInspect;
+ }
+
+ public String getBaseUrl() {
+ return this.host + ":" + this.port + "/" + this.prePath;
+ }
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/config/RestTemplateConfig.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/config/RestTemplateConfig.java
new file mode 100644
index 0000000..5a7dc87
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/config/RestTemplateConfig.java
@@ -0,0 +1,22 @@
+package com.vincent.rsf.server.api.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * @author Ryan
+ * @version 1.0
+ * @title RestTemplateConfig
+ * @description
+ * @create 2025/3/7 10:01
+ */
+
+@Configuration
+public class RestTemplateConfig {
+
+ @Bean
+ public RestTemplate getInstant() {
+ return new RestTemplate();
+ }
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/entity/dto/PoItemsDto.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/entity/dto/PoItemsDto.java
new file mode 100644
index 0000000..01aa9f7
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/entity/dto/PoItemsDto.java
@@ -0,0 +1,43 @@
+package com.vincent.rsf.server.api.entity.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @author Ryan
+ * @version 1.0
+ * @title PoItemsDto
+ * @description
+ * @create 2025/3/7 08:49
+ */
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "PoItemsDto", description = "PO鍗曟嵁")
+public class PoItemsDto implements Serializable {
+
+ @ApiModelProperty("PO鍗曟槑缁嗘爣璇�")
+ private String id;
+
+ @ApiModelProperty("PO涓诲崟鏍囪瘑")
+ private String purchaseId;
+
+ @ApiModelProperty("Erp鏄庣粏鍗曟爣璇�")
+ private String erpItemId;
+
+ @ApiModelProperty("鐗╂枡缂栫爜")
+ private String matnrCode;
+
+ @ApiModelProperty("鐗╂枡鍚嶇О")
+ private String matnrName;
+
+ @ApiModelProperty("璁¢噺鍗曚綅")
+ private String unit;
+
+ @ApiModelProperty("鏁伴噺")
+ private String anfme;
+
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/entity/params/ErpInspectItem.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/entity/params/ErpInspectItem.java
new file mode 100644
index 0000000..080da32
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/entity/params/ErpInspectItem.java
@@ -0,0 +1,38 @@
+package com.vincent.rsf.server.api.entity.params;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author Ryan
+ * @version 1.0
+ * @title ErpInspectItem
+ * @description
+ * @create 2025/3/7 09:35
+ */
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "ErpInspectItem", description = "Erp璐ㄦ鍗曟嵁鏄庣粏")
+public class ErpInspectItem {
+
+ /**
+ * erp鏄庣粏缂栫爜
+ */
+ public String poItemId;
+
+ /**
+ * 鐗╂枡缂栫爜
+ */
+ public String matnrCode;
+
+ /**
+ * 璁¢噺鍗曚綅
+ */
+ public String unit;
+
+ /**
+ * 鏁伴噺
+ */
+ public Double anfme;
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/entity/params/ErpInspectParams.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/entity/params/ErpInspectParams.java
new file mode 100644
index 0000000..76badb5
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/entity/params/ErpInspectParams.java
@@ -0,0 +1,36 @@
+package com.vincent.rsf.server.api.entity.params;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author Ryan
+ * @version 1.0
+ * @title ErpInspectParams
+ * @description
+ * @create 2025/3/6 15:08
+ */
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "ErpInspectParams", description = "Erp璐ㄦ鍗曟嵁")
+public class ErpInspectParams implements Serializable {
+
+ /**
+ * 涓诲崟鏍囪瘑
+ */
+ public String poId;
+ /**
+ * 涓诲崟缂栫爜
+ */
+ private String poCode;
+ /**
+ * 璐ㄦ鏄庣粏
+ */
+ private List<ErpInspectItem> children;
+
+}
+
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/ErpApiService.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/ErpApiService.java
index a241420..266c842 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/ErpApiService.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/ErpApiService.java
@@ -2,6 +2,7 @@
import com.vincent.rsf.server.api.controller.params.Order;
+import com.vincent.rsf.server.api.entity.dto.PoItemsDto;
import java.util.List;
@@ -15,4 +16,6 @@
public interface ErpApiService {
boolean syncPurchasee(List<Order> orders);
+
+ boolean reportInspectNotify(List<PoItemsDto> items);
}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ErpApiServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ErpApiServiceImpl.java
index 212ea4e..47b143f 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ErpApiServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ErpApiServiceImpl.java
@@ -1,8 +1,23 @@
package com.vincent.rsf.server.api.service.impl;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
+import com.vincent.rsf.common.domain.CommonReponse;
import com.vincent.rsf.framework.exception.CoolException;
+import com.vincent.rsf.server.api.config.RemotesInfoProperties;
+import com.vincent.rsf.server.api.entity.dto.PoItemsDto;
import com.vincent.rsf.server.api.entity.enums.OrderType;
+import com.vincent.rsf.server.api.entity.params.ErpInspectItem;
+import com.vincent.rsf.server.api.entity.params.ErpInspectParams;
+import com.vincent.rsf.server.common.config.SysStockFlowProperties;
+import com.vincent.rsf.server.manager.entity.AsnOrder;
+import com.vincent.rsf.server.manager.entity.AsnOrderItem;
import com.vincent.rsf.server.manager.entity.PurchaseItem;
+import com.vincent.rsf.server.manager.service.AsnOrderItemService;
+import com.vincent.rsf.server.manager.service.AsnOrderService;
import com.vincent.rsf.server.manager.service.PurchaseItemService;
import com.vincent.rsf.server.manager.service.PurchaseService;
import com.vincent.rsf.server.system.constant.SerialRuleCode;
@@ -10,13 +25,21 @@
import com.vincent.rsf.server.system.utils.SerialRuleUtils;
import com.vincent.rsf.server.api.service.ErpApiService;
import com.vincent.rsf.server.manager.entity.Purchase;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* @author Ryan
@@ -25,14 +48,26 @@
* @description
* @create 2025/3/4 16:27
*/
+@Slf4j
@Service("erpApiService")
public class ErpApiServiceImpl implements ErpApiService {
@Autowired
private PurchaseService purchaseService;
-
@Autowired
private PurchaseItemService purchaseItemService;
+
+ @Autowired
+ private AsnOrderService asnOrderService;
+
+ @Autowired
+ private AsnOrderItemService asnOrderItemService;
+ @Autowired
+ private RestTemplate restTemplate;
+ @Autowired
+ private RemotesInfoProperties remotesInfoProperties;
+ @Autowired
+ private RemotesInfoProperties.ApiInfo apiInfo;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -67,4 +102,106 @@
return true;
}
+ /**
+ * @author Ryan
+ * @description 涓婃姤璐ㄦ鍒楄〃
+ * @params [items 鍒楄〃]
+ * @return boolean
+ * @time 2025/3/7 09:12
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public boolean reportInspectNotify(List<PoItemsDto> items) {
+ if (items.isEmpty()) {
+ throw new CoolException("涓婃姤鍐呭涓虹┖锛侊紒");
+ }
+ List<ErpInspectParams> inspectParams = new ArrayList<>();
+ Map<String, List<PoItemsDto>> listMap = items.stream().collect(Collectors.groupingBy(PoItemsDto::getPurchaseId));
+ listMap.keySet().forEach(key -> {
+ Purchase purchase = purchaseService.getOne(new LambdaQueryWrapper<Purchase>().eq(Purchase::getId, Long.valueOf(key)));
+ if (Objects.isNull(purchase)) {
+ throw new CoolException("閲囪喘鍗曚俊鎭湁璇紒锛�");
+ }
+ ErpInspectParams params = new ErpInspectParams();
+ List<ErpInspectItem> inspectItems = new ArrayList<>();
+ //璧嬪�糴rp涓诲崟缂栫爜,缂栧彿
+ params.setPoId(purchase.getErpId())
+ .setPoCode(purchase.getErpCode());
+ List<PoItemsDto> dtos = listMap.get(key);
+ if (dtos.isEmpty()) {
+ throw new CoolException("鍗曟嵁淇℃伅閿欒锛侊紒");
+ }
+ dtos.forEach(dto -> {
+ ErpInspectItem inspect= new ErpInspectItem();
+ BeanUtils.copyProperties(dto, inspect);
+ //璧嬪�糴rp鏄庣粏缂栫爜
+ inspect.setPoItemId(dto.getErpItemId());
+ inspectItems.add(inspect);
+ });
+ params.setChildren(inspectItems);
+ inspectParams.add(params);
+
+ });
+
+ MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
+ //鑾峰彇涓婃姤璐ㄦ鎺ュ彛
+ String url = remotesInfoProperties.getBaseUrl() + apiInfo.getNotifyInspect();
+ // 璁剧疆璇锋眰鍙傛暟
+ params.add("params", JSONObject.toJSONString(inspectParams));
+ log.info("璇锋眰鍦板潃锛歿}锛岃姹傚弬鏁帮細{}", url, JSONObject.toJSONString(inspectParams));
+ HttpHeaders headers = new HttpHeaders();
+ headers.add("Content-Type", "application/json");
+ HttpEntity httpEntity = new HttpEntity<>(params, headers);
+ // 璇锋眰
+ ResponseEntity<String> exchange = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
+ log.info("涓嬪彂浠诲姟 杩斿洖缁撴灉锛歿}", exchange);
+ if (Objects.isNull(exchange.getBody()) || exchange.getBody() == null) {
+ throw new CoolException("涓嬪彂浠诲姟澶辫触锛侊紒");
+ } else {
+ CommonReponse reponse = (CommonReponse) JSON.parse(exchange.getBody());
+ if (reponse.getCode() == 0) {
+ //淇敼asn涓婃姤鐘舵��
+ Set<String> itemSets = items.stream().map(PoItemsDto::getId).collect(Collectors.toSet());
+ Set<Long> longSet = new HashSet<>();
+ itemSets.forEach(set -> {
+ longSet.add(Long.parseLong(set));
+ });
+
+ List<AsnOrderItem> asnOrderItems = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>().in(AsnOrderItem::getPoDetlId, longSet));
+ if (asnOrderItems.isEmpty()) {
+ throw new CoolException("ASN鍗曟嵁涓嶅瓨鍦紒锛�");
+ }
+ List<Long> list = asnOrderItems.stream().map(AsnOrderItem::getId).collect(Collectors.toList());
+
+ /************************** 淇敼ASN鏄庣粏鍗曠姸鎬� ******************************/
+
+
+ if (!asnOrderItemService.update(new LambdaUpdateWrapper<AsnOrderItem>().in(AsnOrderItem::getId, list).set(AsnOrderItem::getStatus, 1))) {
+ throw new CoolException("ASN鏄庣粏鍗曟嵁鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+
+ /************************** 淇敼ASN涓诲崟鏁版嵁 ******************************/
+ //鑾峰彇ASN鏄庣粏璁㈠崟鏍囪瘑
+ List<Long> ids = asnOrderItems.stream().map(AsnOrderItem::getAsnId).collect(Collectors.toList());
+ //ASN鏄庣粏鍗曟嵁鍒嗙粍
+ Map<Long, List<AsnOrderItem>> asnIds = asnOrderItems.stream().collect(Collectors.groupingBy(AsnOrderItem::getAsnId));
+ ids.forEach(id -> {
+ int count = asnOrderService.count(new LambdaQueryWrapper<AsnOrder>().in(AsnOrder::getId, id));
+ if (count == asnIds.get(id).size()) {
+ if (!asnOrderService.update(new LambdaUpdateWrapper<AsnOrder>().eq(AsnOrder::getId, id).set(AsnOrder::getStatus, 1))) {
+ throw new CoolException("ASN涓诲崟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+ } else {
+ if (!asnOrderService.update(new LambdaUpdateWrapper<AsnOrder>().eq(AsnOrder::getId, id).set(AsnOrder::getStatus, 2))) {
+ throw new CoolException("ASN涓诲崟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+ }
+ });
+ return true;
+ } else {
+ throw new CoolException(reponse.getMsg());
+ }
+ }
+ }
+
}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/common/config/SysStockFlowProperties.java b/rsf-server/src/main/java/com/vincent/rsf/server/common/config/SysStockFlowProperties.java
index 292f461..c08e6c6 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/common/config/SysStockFlowProperties.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/common/config/SysStockFlowProperties.java
@@ -18,6 +18,15 @@
public class SysStockFlowProperties {
+ /**
+ * wms鏄惁鍏佽鎵撳嵃璐х墿鏍囩, 榛樿鍙墦鍗�
+ */
+ private Boolean flagPrinter;
+
+ /**
+ * 鏄惁鑷姩鐢熸垚ASN鍗曪紙榛樿锛氭槸锛夛紝涓恒�庡惁銆忓垯寮�鍚疨O鍗曟墜鍔ㄧ敓鎴怉SN鍗曞姛鑳�
+ */
+ private Boolean flagAutoAsn;
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/AsnOrderController.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/AsnOrderController.java
index 7343d00..6144741 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/AsnOrderController.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/AsnOrderController.java
@@ -109,12 +109,22 @@
ExcelUtil.build(ExcelUtil.create(asnOrderService.list(), AsnOrder.class), response);
}
+ /**
+ * 璐ㄦ涓婃姤
+ * @param orders
+ * @return
+ */
@PostMapping("/asnOrder/inspect")
@PreAuthorize("hasAuthority('manager:asnOrder:list')")
- public R inspect(@RequestBody List<AsnOrder> orders) {
-
-
- return R.ok();
+ public R notifyInspect(@RequestBody List<AsnOrder> orders) {
+ if (orders.isEmpty()) {
+ return R.error("涓婃姤鍗曟嵁涓嶈兘涓虹┖!!");
+ }
+ if (asnOrderService.notifyInspect(orders)) {
+ return R.ok("璐ㄦ涓婃姤鎴愬姛锛侊紒");
+ } else {
+ return R.error("涓�閿笂鎶ュけ璐ワ紒锛�");
+ }
}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/AsnOrder.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/AsnOrder.java
index e07af37..f9fa8da 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/AsnOrder.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/AsnOrder.java
@@ -95,6 +95,12 @@
private Date arrTime;
/**
+ * 璐ㄦ涓婃姤鐘舵��
+ */
+ @ApiModelProperty("涓婃姤鐘舵�� 0锛氭湭涓婃姤, 1锛氬凡涓婃姤")
+ private Integer ntyStatus;
+
+ /**
* 閲婃斁鐘舵�� 0: 姝e父 1: 宸查噴鏀�
*/
@ApiModelProperty(value= "閲婃斁鐘舵�� 0: 姝e父 1: 宸查噴鏀� ")
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Purchase.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Purchase.java
index 732ecdc..3de8476 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Purchase.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Purchase.java
@@ -55,6 +55,10 @@
@ApiModelProperty(value= "鍗曟嵁绫诲瀷")
private String type;
+
+ @ApiModelProperty(value = "erp涓诲崟鏍囪瘑")
+ private String erpId;
+
/**
* 鍗曟嵁鏉ユ簮
*/
@@ -171,10 +175,11 @@
public Purchase() {}
- public Purchase(String code,String type,String source,Date preArr,Double anfme,Double qty,Double workQty,String channel,String erpCode,Date startTime,Date endTime,String project,Integer status,Integer deleted,Integer tenantId,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) {
+ public Purchase(String code,String type,String source,String erpId ,Date preArr,Double anfme,Double qty,Double workQty,String channel,String erpCode,Date startTime,Date endTime,String project,Integer status,Integer deleted,Integer tenantId,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) {
this.code = code;
this.type = type;
this.source = source;
+ this.erpId = erpId;
this.preArr = preArr;
this.anfme = anfme;
this.qty = qty;
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/PurchaseItem.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/PurchaseItem.java
index a9c82a5..0ae2108 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/PurchaseItem.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/PurchaseItem.java
@@ -47,7 +47,7 @@
* erp琛屽彿
*/
@ApiModelProperty(value= "erp琛屽彿")
- private String erpId;
+ private String erpItemId;
/**
* 鐗╂枡缂栫爜
@@ -168,9 +168,9 @@
public PurchaseItem() {}
- public PurchaseItem(Long purchaseId,String erpId,String matnrCode,String matnrName,String unit,Double anfme,Double qty,Double nromQty,Double asnQty,Double printQty,String splrName,String splrCode,String splrBatch,Integer status,Integer deleted,Integer tenantId,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) {
+ public PurchaseItem(Long purchaseId,String erpItemId,String matnrCode,String matnrName,String unit,Double anfme,Double qty,Double nromQty,Double asnQty,Double printQty,String splrName,String splrCode,String splrBatch,Integer status,Integer deleted,Integer tenantId,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) {
this.purchaseId = purchaseId;
- this.erpId = erpId;
+ this.erpItemId = erpItemId;
this.matnrCode = matnrCode;
this.matnrName = matnrName;
this.unit = unit;
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/mapper/PurchaseMapper.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/mapper/PurchaseMapper.java
index 7a4c6ef..535e9d7 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/mapper/PurchaseMapper.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/mapper/PurchaseMapper.java
@@ -1,12 +1,18 @@
package com.vincent.rsf.server.manager.mapper;
+import com.vincent.rsf.server.api.entity.dto.PoItemsDto;
import com.vincent.rsf.server.manager.entity.Purchase;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Set;
@Mapper
@Repository
public interface PurchaseMapper extends BaseMapper<Purchase> {
+ List<PoItemsDto> poList(@Param("ids") Set<Long> ids);
}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/ScheduleJobs.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/ScheduleJobs.java
similarity index 92%
rename from rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/ScheduleJobs.java
rename to rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/ScheduleJobs.java
index 1513cd5..eea897f 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/ScheduleJobs.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/ScheduleJobs.java
@@ -1,7 +1,8 @@
-package com.vincent.rsf.server.manager.utils;
+package com.vincent.rsf.server.manager.schedules;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.vincent.rsf.framework.exception.CoolException;
+import com.vincent.rsf.server.common.config.SysStockFlowProperties;
import com.vincent.rsf.server.common.utils.DateUtils;
import com.vincent.rsf.server.manager.entity.*;
import com.vincent.rsf.server.manager.service.*;
@@ -12,6 +13,7 @@
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
+import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -40,6 +42,9 @@
@Autowired
private AsnOrderItemService asnOrderItemService;
+
+ @Resource
+ private SysStockFlowProperties flowProperties;
/**
* @author Ryan
* @description 鏍规嵁PO鍗曟嵁鐢熸垚ASN鍗�,鑷姩鐢熸垚ASN鍗曚负鍏ㄩ噺鐢熸垚
@@ -50,6 +55,10 @@
@Scheduled(cron = "0 0/30 * * * ? ")
@Transactional(rollbackFor = Exception.class)
public void genAsnOrder() {
+ //鍒ゆ柇鏄惁寮�鍚嚜鍔ㄧ敓鎴怉SN鍗曟嵁
+ if (!flowProperties.getFlagAutoAsn()) {
+ return;
+ }
//鑾峰彇鏈敓鎴怉SN鍗曟嵁
List<Purchase> purchases = purchaseService.list(new LambdaQueryWrapper<Purchase>().eq(Purchase::getStatus, 0));
//閲囪喘鍗曚负绌猴紝鐩存帴璺冲嚭褰撳墠浠诲姟
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/AsnOrderService.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/AsnOrderService.java
index 54b0fe9..3415d00 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/AsnOrderService.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/AsnOrderService.java
@@ -3,6 +3,9 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.vincent.rsf.server.manager.entity.AsnOrder;
+import java.util.List;
+
public interface AsnOrderService extends IService<AsnOrder> {
+ boolean notifyInspect(List<AsnOrder> orders);
}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderServiceImpl.java
index 8906fbf..61f0632 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderServiceImpl.java
@@ -1,12 +1,58 @@
package com.vincent.rsf.server.manager.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.vincent.rsf.framework.exception.CoolException;
+import com.vincent.rsf.server.api.entity.dto.PoItemsDto;
+import com.vincent.rsf.server.api.service.ErpApiService;
+import com.vincent.rsf.server.manager.entity.AsnOrderItem;
+import com.vincent.rsf.server.manager.entity.Purchase;
+import com.vincent.rsf.server.manager.entity.PurchaseItem;
+import com.vincent.rsf.server.manager.mapper.AsnOrderItemMapper;
import com.vincent.rsf.server.manager.mapper.AsnOrderMapper;
import com.vincent.rsf.server.manager.entity.AsnOrder;
+import com.vincent.rsf.server.manager.mapper.PurchaseMapper;
import com.vincent.rsf.server.manager.service.AsnOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * @author Ryan
+ * @description
+ * @throws
+ * @return
+ * @time 2025/3/7 08:02
+ */
@Service("asnOrderService")
public class AsnOrderServiceImpl extends ServiceImpl<AsnOrderMapper, AsnOrder> implements AsnOrderService {
+ @Autowired
+ private ErpApiService erpApiService;
+ @Resource
+ private PurchaseMapper purchaseMapper;
+
+ @Resource
+ private AsnOrderItemMapper asnOrderItemMapper;
+
+ @Override
+ public boolean notifyInspect(List<AsnOrder> orders) {
+ if (orders.isEmpty()) {
+ throw new CoolException("涓婃姤鍙傛暟涓嶈兘涓虹┖锛侊紒");
+ }
+ Set<Long> asnIds = orders.stream().map(AsnOrder::getId).collect(Collectors.toSet());
+ if (asnIds.isEmpty()) {
+ throw new CoolException("ASN鍗曟嵁涓嶈兘涓虹┖锛侊紒");
+ }
+ List<PoItemsDto> items = purchaseMapper.poList(asnIds);
+ if (erpApiService.reportInspectNotify(items)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
}
diff --git a/rsf-server/src/main/resources/application-dev.yml b/rsf-server/src/main/resources/application-dev.yml
index 53ce113..34623d8 100644
--- a/rsf-server/src/main/resources/application-dev.yml
+++ b/rsf-server/src/main/resources/application-dev.yml
@@ -67,8 +67,30 @@
timeout: 5000
index: 15
+#骞冲彴鎺ュ彛淇℃伅閰嶇疆(濡傦細ERP, QMS, WCS绛�)
+platform:
+ #浼佷笟ERP骞冲彴
+ erp:
+ #localhost
+ host: http://127.0.0.1
+ #绔彛鍙�
+ port: 8080
+ #鎺ュ搧閾炬帴鍓嶇紑
+ prePath: rsf-server
+ #鎺ュ彛鏄庣粏
+ apiInfo:
+ #璐ㄦ涓婃姤鎺ュ彛
+ notifyInspect: /report/inspect
+
+#浠撳簱鍔熻兘鍙傛暟閰嶇疆
stock:
+ #鏄惁鍏佽鎵撳嵃璐х墿鏍囩锛� 榛樿鍏佽鎵撳嵃锛屼篃鍙敱渚涘簲鍟嗘彁渚涙爣绛�
flagPrinter: false
+ #鏄惁鑷姩鐢熸垚ASN鍗曪紙榛樿锛氭槸锛夛紝涓恒�庡惁銆忓垯寮�鍚疨O鍗曟墜鍔ㄧ敓鎴怉SN鍗曞姛鑳�
+ flagAutoAsn: true
+ #璐ㄦ鍔熻兘 鏄惁鏍¢獙涓婃灦锛堥粯璁わ細鏄級锛屾槸鍚︽牎楠屾敹璐э紙榛樿锛氬惁锛�
inspect:
+ #鍒ゆ柇鏄悗妫�楠屽悎鏍煎悗锛屾墠鍏佽涓婃灦
flagAvailable: true
+ #鍒ゆ柇鏄惁鏍¢獙鍚堟牸鍚庯紝鎵嶅厑璁告敹璐�
flagReceiving: false
\ No newline at end of file
diff --git a/rsf-server/src/main/resources/mapper/manager/PurchaseMapper.xml b/rsf-server/src/main/resources/mapper/manager/PurchaseMapper.xml
index b1c92ce..60ab306 100644
--- a/rsf-server/src/main/resources/mapper/manager/PurchaseMapper.xml
+++ b/rsf-server/src/main/resources/mapper/manager/PurchaseMapper.xml
@@ -2,4 +2,27 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.vincent.rsf.server.manager.mapper.PurchaseMapper">
+ <select id="poList" resultType="com.vincent.rsf.server.api.entity.dto.PoItemsDto">
+ SELECT
+ id,
+ purchase_id,
+ erp_item_id,
+ matnr_code,
+ matnr_name,
+ unit,
+ anfme
+ FROM
+ man_purchase_item mpi
+ WHERE
+ id IN ( SELECT po_detl_id FROM man_asn_order_item
+ <where>
+ 1 = 1
+ <if test="ids != null and ids.size() > 0">
+ <foreach collection="ids" index="index" item="item" separator="," open="AND asn_id IN (" close=")">
+ #{item}
+ </foreach>
+ </if>
+ </where>
+ )
+ </select>
</mapper>
--
Gitblit v1.9.1