|
|
|
@ -1,40 +1,43 @@
|
|
|
|
|
package com.glxp.udi.admin.thread;
|
|
|
|
|
|
|
|
|
|
import com.glxp.udi.admin.controller.inout.InoutUtils;
|
|
|
|
|
import com.glxp.udi.admin.entity.inout.ErpOrderEntity;
|
|
|
|
|
import com.glxp.udi.admin.entity.inout.OrderEntity;
|
|
|
|
|
import com.glxp.udi.admin.entity.inout.OrderMdEntity;
|
|
|
|
|
import com.glxp.udi.admin.entity.inout.WarehouseEntity;
|
|
|
|
|
import com.glxp.udi.admin.entity.inout.Warehousetemp;
|
|
|
|
|
import com.glxp.udi.admin.entity.inout.WarehousetempEntity;
|
|
|
|
|
import com.glxp.udi.admin.mongo.service.OrderDetailMdService;
|
|
|
|
|
import com.glxp.udi.admin.mongo.service.OrderMdService;
|
|
|
|
|
import com.glxp.udi.admin.mongo.service.WarehouseMdService;
|
|
|
|
|
import com.glxp.udi.admin.mongo.service.WarehouseTempMdService;
|
|
|
|
|
import com.glxp.udi.admin.req.inout.CommitRequest;
|
|
|
|
|
import com.glxp.udi.admin.req.inout.FilterErpOrderRequest;
|
|
|
|
|
import com.glxp.udi.admin.req.inout.OrderFilterRequest;
|
|
|
|
|
import com.glxp.udi.admin.req.inout.DeleteRequest;
|
|
|
|
|
import com.glxp.udi.admin.req.inout.PostOrderRequest;
|
|
|
|
|
import com.glxp.udi.admin.req.inout.WarehouseQueryRequest;
|
|
|
|
|
import com.glxp.udi.admin.service.info.SetupService;
|
|
|
|
|
import com.glxp.udi.admin.service.inout.*;
|
|
|
|
|
import com.glxp.udi.admin.service.inout.MyErpOrderService;
|
|
|
|
|
import com.glxp.udi.admin.service.inout.UdiInfoService;
|
|
|
|
|
import com.glxp.udi.admin.service.inout.UdiRelevanceService;
|
|
|
|
|
import com.glxp.udi.admin.service.receipts.MipsBarcodeService;
|
|
|
|
|
import com.glxp.udi.admin.service.receipts.ProductInfoService;
|
|
|
|
|
import com.glxp.udi.admin.service.receipts.ProductService;
|
|
|
|
|
import com.glxp.udi.admin.util.WarehousBeanUtils;
|
|
|
|
|
import com.glxp.udi.admin.util.DateUtil;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class TransInoutService {
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(TransInoutService.class);
|
|
|
|
|
@Resource
|
|
|
|
|
private WarehouseService warehouseService;
|
|
|
|
|
@Resource
|
|
|
|
|
private OrderService orderService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private MipsBarcodeService mipsBarcodeService;
|
|
|
|
|
@Resource
|
|
|
|
@ -54,6 +57,18 @@ public class TransInoutService {
|
|
|
|
|
@Value("${UDI_SERVER_URL}")
|
|
|
|
|
private String udiUrl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private OrderMdService orderService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private WarehouseTempMdService warehouseTempMdService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private WarehouseMdService warehouseMdService;
|
|
|
|
|
@Resource
|
|
|
|
|
private OrderDetailMdService orderDetailMdService;
|
|
|
|
|
|
|
|
|
|
@Async
|
|
|
|
|
public void transInout(PostOrderRequest postOrderRequest, long customerId) {
|
|
|
|
|
|
|
|
|
@ -61,57 +76,51 @@ public class TransInoutService {
|
|
|
|
|
if (postOrders != null && postOrders.size() > 0) {
|
|
|
|
|
for (int i = 0; i < postOrders.size(); i++) {
|
|
|
|
|
PostOrderRequest.PostOrder postOrder = postOrders.get(i);
|
|
|
|
|
List<WarehouseEntity> warehouseEntityList = postOrder.getCodes();
|
|
|
|
|
List<Warehousetemp> warehousetempList = new WarehousBeanUtils().entityToTemp(warehouseEntityList, customerId);
|
|
|
|
|
List<WarehousetempEntity> warehousetempList = postOrder.getCodes();
|
|
|
|
|
if (warehousetempList != null && warehousetempList.size() > 0) {
|
|
|
|
|
Warehousetemp warehouseEntity = warehousetempList.get(0);
|
|
|
|
|
WarehousetempEntity warehousetempEntity = warehousetempList.get(0);
|
|
|
|
|
String orderId = System.currentTimeMillis() + i + "";
|
|
|
|
|
OrderEntity orderSaveRequest = new OrderEntity();
|
|
|
|
|
orderSaveRequest.setId(orderId);
|
|
|
|
|
if (warehouseEntity.getActdate() != null) {
|
|
|
|
|
orderSaveRequest.setActDate(warehouseEntity.getActdate());
|
|
|
|
|
}
|
|
|
|
|
OrderMdEntity orderSaveRequest = new OrderMdEntity();
|
|
|
|
|
orderSaveRequest.setOrderId(orderId);
|
|
|
|
|
Date actDate = DateUtil.parseDate(warehousetempEntity.getActDate());
|
|
|
|
|
orderSaveRequest.setActDate(DateUtil.dateToISODate(actDate));
|
|
|
|
|
orderSaveRequest.setCustomerId(customerId);
|
|
|
|
|
orderSaveRequest.setAction(warehouseEntity.getAction());
|
|
|
|
|
orderSaveRequest.setActor(warehouseEntity.getActor());
|
|
|
|
|
orderSaveRequest.setCorpOrderId(warehouseEntity.getCorporderid());
|
|
|
|
|
orderSaveRequest.setFromCorpId(warehouseEntity.getFromcorpid());
|
|
|
|
|
orderSaveRequest.setMainAction(warehouseEntity.getMainaction());
|
|
|
|
|
orderSaveRequest.setFromCorp(warehouseEntity.getFromcorp());
|
|
|
|
|
orderSaveRequest.setAction(warehousetempEntity.getAction());
|
|
|
|
|
orderSaveRequest.setActor(warehousetempEntity.getActor());
|
|
|
|
|
orderSaveRequest.setCorpOrderId(warehousetempEntity.getCorpOrderId());
|
|
|
|
|
orderSaveRequest.setFromCorpId(warehousetempEntity.getFromCorpId());
|
|
|
|
|
orderSaveRequest.setMainAction(warehousetempEntity.getMainAction());
|
|
|
|
|
orderSaveRequest.setFromCorp(warehousetempEntity.getFromCorp());
|
|
|
|
|
orderSaveRequest.setFromType("手持终端");
|
|
|
|
|
orderSaveRequest.setStatus("process");
|
|
|
|
|
orderSaveRequest.setExportStatus("未上传");
|
|
|
|
|
orderSaveRequest.setStockCheckFk(postOrder.getStockIdFk());
|
|
|
|
|
orderSaveRequest.setSignStatus("0");
|
|
|
|
|
List<String> docidsList = postOrder.getErpOrders();
|
|
|
|
|
String docidStr = "";
|
|
|
|
|
if (docidsList != null) {
|
|
|
|
|
for (String key : docidsList) {
|
|
|
|
|
docidStr = docidStr + "," + key;
|
|
|
|
|
}
|
|
|
|
|
if (docidStr.length() > 1) {
|
|
|
|
|
docidStr = docidStr.substring(1);
|
|
|
|
|
orderSaveRequest.setErpFk(docidStr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
orderService.insertOrder(orderSaveRequest);
|
|
|
|
|
for (int index = 0; index < warehousetempList.size(); index++) {
|
|
|
|
|
warehousetempList.get(index).setOrderid(orderId);
|
|
|
|
|
warehousetempList.get(index).setOrderId(orderId);
|
|
|
|
|
}
|
|
|
|
|
warehouseService.insertTempWarehouses(warehousetempList);
|
|
|
|
|
List<Warehousetemp> filterList = warehousetempList;
|
|
|
|
|
List<Warehousetemp> insertList = new ArrayList<>();
|
|
|
|
|
warehouseTempMdService.insertTempWarehouses(warehousetempList);
|
|
|
|
|
List<WarehousetempEntity> filterList = warehousetempList;
|
|
|
|
|
List<WarehousetempEntity> insertList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
//更新状态,正在处理
|
|
|
|
|
OrderMdEntity tempEntity = new OrderMdEntity();
|
|
|
|
|
tempEntity.setOrderId(filterList.get(0).getOrderId());
|
|
|
|
|
tempEntity.setRemark("正在处理");
|
|
|
|
|
orderService.updateOrder(tempEntity);
|
|
|
|
|
|
|
|
|
|
String result;
|
|
|
|
|
orderService.updateRemark(filterList.get(0).getOrderid(), "正在处理");
|
|
|
|
|
for (int j = 0; j < filterList.size(); j++) {
|
|
|
|
|
Warehousetemp warehousetemp = filterList.get(j);
|
|
|
|
|
result = new InoutUtils().filterCode(warehouseService, warehousetemp, setupService);
|
|
|
|
|
WarehousetempEntity warehousetemp = filterList.get(j);
|
|
|
|
|
result = new InoutUtils().filterCode(warehouseMdService, warehousetemp, setupService);
|
|
|
|
|
if (result == null) {
|
|
|
|
|
insertList.add(warehousetemp);
|
|
|
|
|
} else {
|
|
|
|
|
orderService.updateOrderStatus(warehousetemp.getOrderid(), "error");
|
|
|
|
|
orderService.updateRemark(warehousetemp.getOrderid(), result);
|
|
|
|
|
//更新状态,失败
|
|
|
|
|
OrderMdEntity tempEntity1 = new OrderMdEntity();
|
|
|
|
|
tempEntity1.setOrderId(filterList.get(0).getOrderId());
|
|
|
|
|
tempEntity1.setStatus("error");
|
|
|
|
|
tempEntity1.setRemark(result);
|
|
|
|
|
orderService.updateOrder(tempEntity1);
|
|
|
|
|
insertList.clear();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -119,18 +128,24 @@ public class TransInoutService {
|
|
|
|
|
postOrders.get(i).setOrderId(orderId);
|
|
|
|
|
|
|
|
|
|
if (insertList.size() > 0) {
|
|
|
|
|
orderId = insertList.get(0).getOrderid();
|
|
|
|
|
warehouseService.insertWarehouses(new WarehousBeanUtils().tempsToEntitys(insertList));
|
|
|
|
|
Warehousetemp warehousetemp = insertList.get(0);
|
|
|
|
|
CommitRequest commitRequest = new CommitRequest();
|
|
|
|
|
commitRequest.setOrderId(warehousetemp.getOrderid());
|
|
|
|
|
List<Warehousetemp> warehousetemps = warehouseService.findTempByOrderId(commitRequest);
|
|
|
|
|
orderService.updateOrderStatus(orderId, "success");
|
|
|
|
|
List<Long> ids = new ArrayList<>();
|
|
|
|
|
for (Warehousetemp w : warehousetemps) {
|
|
|
|
|
ids.add(w.getId());
|
|
|
|
|
}
|
|
|
|
|
warehouseService.deleteTempWarehouses(ids);
|
|
|
|
|
orderId = insertList.get(0).getOrderId();
|
|
|
|
|
List<WarehouseEntity> warehouseEntities = insertList.stream().map(e -> {
|
|
|
|
|
WarehouseEntity warehouseEntity = new WarehouseEntity();
|
|
|
|
|
BeanUtils.copyProperties(e, warehouseEntity);
|
|
|
|
|
return warehouseEntity;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
warehouseMdService.insertWarehouses(warehouseEntities);
|
|
|
|
|
|
|
|
|
|
//更新状态,成功
|
|
|
|
|
OrderMdEntity tempEntity2 = new OrderMdEntity();
|
|
|
|
|
tempEntity2.setOrderId(filterList.get(0).getOrderId());
|
|
|
|
|
tempEntity2.setStatus("success");
|
|
|
|
|
orderService.updateOrder(tempEntity2);
|
|
|
|
|
|
|
|
|
|
//删除零时表数据
|
|
|
|
|
DeleteRequest deleteRequest = new DeleteRequest();
|
|
|
|
|
deleteRequest.setOrderId(orderId);
|
|
|
|
|
warehouseTempMdService.deleteCode(deleteRequest);
|
|
|
|
|
insertList.clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -139,8 +154,10 @@ public class TransInoutService {
|
|
|
|
|
//生成对照表
|
|
|
|
|
for (int i = 0; i < postOrders.size(); i++) {
|
|
|
|
|
PostOrderRequest.PostOrder postOrder = postOrders.get(i);
|
|
|
|
|
List<WarehouseEntity> transData = warehouseService.findByReceiptId(postOrder.getOrderId());
|
|
|
|
|
new InoutUtils(udiUrl).generateConstrastDetail(udiInfoService, udiRelevanceService, myErpOrderService, transData);
|
|
|
|
|
WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest();
|
|
|
|
|
warehouseQueryRequest.setOrderId(postOrder.getOrderId());
|
|
|
|
|
List<WarehouseEntity> transData = warehouseMdService.filterWarehouse(warehouseQueryRequest);
|
|
|
|
|
new InoutUtils(udiUrl).generateConstrastDetail(udiInfoService, udiRelevanceService, orderDetailMdService, transData);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -149,93 +166,55 @@ public class TransInoutService {
|
|
|
|
|
|
|
|
|
|
@Async
|
|
|
|
|
public void repeatCommit(CommitRequest commitRequest) {
|
|
|
|
|
List<Warehousetemp> warehousetempList = warehouseService.findTempByOrderId(commitRequest);
|
|
|
|
|
String orderId = commitRequest.getOrderId();
|
|
|
|
|
List<WarehousetempEntity> warehousetempList = warehouseTempMdService.findTempByOrderId(commitRequest.getOrderId());
|
|
|
|
|
if (warehousetempList != null && warehousetempList.size() > 0) {
|
|
|
|
|
String result;
|
|
|
|
|
|
|
|
|
|
List<Warehousetemp> insertList = new ArrayList<>();
|
|
|
|
|
List<WarehousetempEntity> insertList = new ArrayList<>();
|
|
|
|
|
for (int j = 0; j < warehousetempList.size(); j++) {
|
|
|
|
|
Warehousetemp warehousetemp = warehousetempList.get(j);
|
|
|
|
|
result = new InoutUtils().filterCode(warehouseService, warehousetemp, setupService);
|
|
|
|
|
WarehousetempEntity warehousetemp = warehousetempList.get(j);
|
|
|
|
|
result = new InoutUtils().filterCode(warehouseMdService, warehousetemp, setupService);
|
|
|
|
|
if (result == null) {
|
|
|
|
|
insertList.add(warehousetemp);
|
|
|
|
|
} else {
|
|
|
|
|
orderService.updateRemark(warehousetemp.getOrderid(), result);
|
|
|
|
|
OrderMdEntity tempEntity = new OrderMdEntity();
|
|
|
|
|
tempEntity.setOrderId(orderId);
|
|
|
|
|
tempEntity.setRemark(result);
|
|
|
|
|
orderService.updateOrder(tempEntity);
|
|
|
|
|
insertList.clear();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (insertList.size() > 0) {
|
|
|
|
|
warehouseService.insertWarehouses(new WarehousBeanUtils().tempsToEntitys(insertList));
|
|
|
|
|
orderService.updateOrderStatus(insertList.get(0).getOrderid(), "success");
|
|
|
|
|
List<Long> ids = new ArrayList<>();
|
|
|
|
|
for (Warehousetemp warehousetemp : insertList) {
|
|
|
|
|
ids.add(warehousetemp.getId());
|
|
|
|
|
}
|
|
|
|
|
warehouseService.deleteTempWarehouses(ids);
|
|
|
|
|
String orderId = insertList.get(0).getOrderid();
|
|
|
|
|
String type = insertList.get(0).getAction();
|
|
|
|
|
|
|
|
|
|
OrderFilterRequest orderFilterRequest = new OrderFilterRequest();
|
|
|
|
|
orderFilterRequest.setId(orderId);
|
|
|
|
|
OrderEntity orderEntity = orderService.findOne(orderFilterRequest);
|
|
|
|
|
String docidStr = orderEntity.getErpFk();
|
|
|
|
|
String[] docidArray;
|
|
|
|
|
List<String> docids = new ArrayList<>();
|
|
|
|
|
if (docidStr != null && docidStr.length() > 0) {
|
|
|
|
|
docidArray = docidStr.split(",");
|
|
|
|
|
for (int i = 0; i < docidArray.length; i++) {
|
|
|
|
|
docids.add(docidArray[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (docids == null || docids.size() == 0) {
|
|
|
|
|
FilterErpOrderRequest filterErpOrderRequest = new FilterErpOrderRequest();
|
|
|
|
|
filterErpOrderRequest.setOrderId(orderId);
|
|
|
|
|
docids = myErpOrderService.filterAllDocid(filterErpOrderRequest);
|
|
|
|
|
docids = getDocids(docids);
|
|
|
|
|
}
|
|
|
|
|
List<WarehouseEntity> datas = warehouseService.findByReceiptId(orderId);
|
|
|
|
|
new InoutUtils(udiUrl).generateConstrastDetail(udiInfoService, udiRelevanceService, myErpOrderService, datas);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<WarehouseEntity> warehouseEntities = insertList.stream().map(e -> {
|
|
|
|
|
WarehouseEntity warehouseEntity = new WarehouseEntity();
|
|
|
|
|
BeanUtils.copyProperties(e, warehouseEntity);
|
|
|
|
|
return warehouseEntity;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
warehouseMdService.insertWarehouses(warehouseEntities);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void updateErpOrderId(List<ErpOrderEntity> erpOrderEntities, String oldId, String newId) {
|
|
|
|
|
if (erpOrderEntities != null) {
|
|
|
|
|
List<ErpOrderEntity> inserts = new ArrayList<>();
|
|
|
|
|
for (ErpOrderEntity erpOrderEntity : erpOrderEntities) {
|
|
|
|
|
if (erpOrderEntity.getOrderIdFk() == null || erpOrderEntity.getOrderIdFk().equals(oldId)) {
|
|
|
|
|
erpOrderEntity.setOrderIdFk(newId);
|
|
|
|
|
inserts.add(erpOrderEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
myErpOrderService.insertErpOrders(inserts);
|
|
|
|
|
}
|
|
|
|
|
//更新状态,成功
|
|
|
|
|
OrderMdEntity tempEntity2 = new OrderMdEntity();
|
|
|
|
|
tempEntity2.setOrderId(orderId);
|
|
|
|
|
tempEntity2.setStatus("success");
|
|
|
|
|
orderService.updateOrder(tempEntity2);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<String> getDocids(List<String> ids) {
|
|
|
|
|
Map<String, String> filter = new HashMap<>();
|
|
|
|
|
List<String> docids = new ArrayList<>();
|
|
|
|
|
for (String id : ids) {
|
|
|
|
|
if (id.contains(",")) {
|
|
|
|
|
String[] dociArray = id.split(",");
|
|
|
|
|
if (dociArray != null && dociArray.length > 0) {
|
|
|
|
|
for (int i = 0; i < dociArray.length; i++) {
|
|
|
|
|
filter.put(dociArray[i], dociArray[i]);
|
|
|
|
|
}
|
|
|
|
|
//删除零时表数据
|
|
|
|
|
DeleteRequest deleteRequest = new DeleteRequest();
|
|
|
|
|
deleteRequest.setOrderId(orderId);
|
|
|
|
|
warehouseTempMdService.deleteCode(deleteRequest);
|
|
|
|
|
|
|
|
|
|
WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest();
|
|
|
|
|
warehouseQueryRequest.setOrderId(orderId);
|
|
|
|
|
List<WarehouseEntity> transData = warehouseMdService.filterWarehouse(warehouseQueryRequest);
|
|
|
|
|
new InoutUtils(udiUrl).generateConstrastDetail(udiInfoService, udiRelevanceService, orderDetailMdService, transData);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
filter.put(id, id);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (String docid : filter.keySet()) {
|
|
|
|
|
docids.add(docid);
|
|
|
|
|
}
|
|
|
|
|
return docids;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|