|
|
|
@ -18,6 +18,7 @@ import com.glxp.api.admin.entity.inout.OrderEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.inout.WarehouseEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.inventory.InvProductDetailEntity;
|
|
|
|
|
import com.glxp.api.admin.httpclient.ErpOrderClient;
|
|
|
|
|
import com.glxp.api.admin.req.basic.FilterCompanyProductRelevanceRequest;
|
|
|
|
|
import com.glxp.api.admin.req.basic.FilterUdiInfoRequest;
|
|
|
|
|
import com.glxp.api.admin.req.business.StockOrderFilterRequest;
|
|
|
|
|
import com.glxp.api.admin.req.inout.CommitRequest;
|
|
|
|
@ -32,6 +33,7 @@ import com.glxp.api.admin.service.basic.UdiInfoService;
|
|
|
|
|
import com.glxp.api.admin.service.basic.UdiRelevanceService;
|
|
|
|
|
import com.glxp.api.admin.service.business.StockOrderDetailService;
|
|
|
|
|
import com.glxp.api.admin.service.business.StockOrderService;
|
|
|
|
|
import com.glxp.api.admin.service.info.CompanyProductRelevanceService;
|
|
|
|
|
import com.glxp.api.admin.service.info.SystemParamConfigService;
|
|
|
|
|
import com.glxp.api.admin.service.inout.CodesService;
|
|
|
|
|
import com.glxp.api.admin.service.inout.CodesTempService;
|
|
|
|
@ -72,7 +74,8 @@ public class IoTransInoutService {
|
|
|
|
|
private UdiInfoService udiInfoService;
|
|
|
|
|
@Value("${UDI_SERVER_URL}")
|
|
|
|
|
private String udiUrl;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
CompanyProductRelevanceService companyProductRelevanceService;
|
|
|
|
|
@Resource
|
|
|
|
|
private CodesTempService codesTempService;
|
|
|
|
|
@Autowired
|
|
|
|
@ -122,9 +125,9 @@ public class IoTransInoutService {
|
|
|
|
|
|
|
|
|
|
WarehouseEntity warehouseEntity = warehouseEntityList.get(0);
|
|
|
|
|
String orderId = "SM" + CustomUtil.getId() + i + "";
|
|
|
|
|
if (warehouseEntity.getOrderId() != null) {
|
|
|
|
|
orderId = warehouseEntity.getOrderId();
|
|
|
|
|
}
|
|
|
|
|
// if (warehouseEntity.getOrderId() != null) {
|
|
|
|
|
// orderId = warehouseEntity.getOrderId();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
OrderEntity orderSaveRequest = new OrderEntity();
|
|
|
|
|
orderSaveRequest.setId(orderId);
|
|
|
|
@ -206,6 +209,9 @@ public class IoTransInoutService {
|
|
|
|
|
orderSaveRequest.setMainAction(warehouseEntity.getMainAction());
|
|
|
|
|
orderSaveRequest.setFromCorp(warehouseEntity.getFromCorp());
|
|
|
|
|
orderSaveRequest.setFromType(ConstantStatus.FROM_WEBNEW);
|
|
|
|
|
orderSaveRequest.setReceiveStatus(0);
|
|
|
|
|
orderSaveRequest.setCreateUser(postOrderRequest.getUserId());
|
|
|
|
|
orderSaveRequest.setLocStorageCode(warehouseEntity.getLocStorageCode());
|
|
|
|
|
orderSaveRequest.setStatus(postOrderRequest.getSubmitType() == 0 ?
|
|
|
|
|
ConstantStatus.ORDER_STATUS_PROCESS : ConstantStatus.ORDER_STATUS_TEMP_SAVE);
|
|
|
|
|
orderSaveRequest.setExportStatus(ConstantStatus.ORDER_EXPORT_UN);
|
|
|
|
@ -248,6 +254,7 @@ public class IoTransInoutService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void transInout(OrderEntity orderEntity) {
|
|
|
|
|
|
|
|
|
|
if (orderEntity.getFromCorp() == null) {
|
|
|
|
@ -324,6 +331,7 @@ public class IoTransInoutService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectByNameCode(warehouseEntity.getNameCode());
|
|
|
|
|
if (udiRelevanceResponse == null) {
|
|
|
|
|
orderService.updateOrderStatus(warehouseEntity.getOrderId(), ConstantStatus.ORDER_STATUS_FAIL);
|
|
|
|
@ -334,46 +342,18 @@ public class IoTransInoutService {
|
|
|
|
|
orderService.updateRemark(orderEntity.getId(), "udi码:" + warehouseEntity.getCode() + "该产品不允许以使用单元入库!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_OUT && bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT)) {
|
|
|
|
|
CompanyProductRelevanceEntity companyProductRelevanceEntity = companyProductRelevanceService.findByUdiRlIdUnitFk(udiRelevanceResponse.getId() + "", warehouseEntity.getFromCorpId());
|
|
|
|
|
if (companyProductRelevanceEntity == null) {
|
|
|
|
|
orderService.updateOrderStatus(warehouseEntity.getOrderId(), ConstantStatus.ORDER_STATUS_FAIL);
|
|
|
|
|
orderService.updateRemark(orderEntity.getId(), udiRelevanceResponse.getCpmctymc() + "该产品非此供应商配送");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (insertList.size() > 0) {
|
|
|
|
|
warehouseService.insertWarehouses(insertList);
|
|
|
|
|
//未所有条码关联基础信息关联表ID
|
|
|
|
|
List<WarehouseEntity> warehouseEntityList = warehouseService.findByReceiptId(orderEntity.getId());
|
|
|
|
|
for (WarehouseEntity warehouseEntity : warehouseEntityList) {
|
|
|
|
|
FilterUdiInfoRequest filterUdiInfoRequest = new FilterUdiInfoRequest();
|
|
|
|
|
filterUdiInfoRequest.setNameCode(warehouseEntity.getNameCode());
|
|
|
|
|
List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceService.filterUdiRelevance(filterUdiInfoRequest);
|
|
|
|
|
if (udiRelevanceEntities != null && udiRelevanceEntities.size() > 1) {
|
|
|
|
|
warehouseEntity.setRelId(null);
|
|
|
|
|
warehouseEntity.setStatus(ConstantStatus.ORDER_DETAIL_DI_MUTI);
|
|
|
|
|
} else if (udiRelevanceEntities == null || udiRelevanceEntities.size() == 0) {
|
|
|
|
|
warehouseEntity.setRelId(null);
|
|
|
|
|
warehouseEntity.setStatus(2);
|
|
|
|
|
} else {
|
|
|
|
|
warehouseEntity.setStatus(0);
|
|
|
|
|
warehouseEntity.setRelId(udiRelevanceEntities.get(0).getId() + "");
|
|
|
|
|
}
|
|
|
|
|
warehouseService.updateCode(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (orderEntity.getErpFk() != null && !"".equals(orderEntity.getErpFk())) {//已经绑定校验单据号,等待校验
|
|
|
|
|
orderService.updateOrderStatus(orderEntity.getId(), ConstantStatus.ORDER_STATUS_CHECK);
|
|
|
|
|
} else {
|
|
|
|
|
//生成单据详情
|
|
|
|
|
inoutUtils.generateConstrastDetail(udiInfoService, udiRelevanceService, myErpOrderService, warehouseEntityList);
|
|
|
|
|
if (bussinessTypeEntity.getThirdSysFk() == null && bussinessTypeEntity.getLocalAction() == null) {//不需要校验
|
|
|
|
|
checkMutiDi(orderEntity.getId()); //校验一个DI是否绑定多个产品ID
|
|
|
|
|
orderEntity = orderService.findById(orderEntity.getId());
|
|
|
|
|
if (orderEntity.getContrastStatus() != ConstantStatus.ORDER_CHECK_FAIL) {
|
|
|
|
|
orderService.updateOrderStatus(orderEntity.getId(), ConstantStatus.ORDER_STATUS_SUCCESS);
|
|
|
|
|
invProductsTrService.genInvProducts(orderEntity.getId());
|
|
|
|
|
}
|
|
|
|
|
} else {//需要校验,等待校验
|
|
|
|
|
orderService.updateOrderStatus(orderEntity.getId(), ConstantStatus.ORDER_STATUS_CHECK);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//删除临时表
|
|
|
|
|
WarehouseQueryRequest tempQuery = new WarehouseQueryRequest();
|
|
|
|
@ -389,10 +369,52 @@ public class IoTransInoutService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* //未所有条码关联基础信息关联表ID
|
|
|
|
|
* List<WarehouseEntity> warehouseEntityList = warehouseService.findByReceiptId(orderEntity.getId());
|
|
|
|
|
* for (WarehouseEntity warehouseEntity : warehouseEntityList) {
|
|
|
|
|
* FilterUdiInfoRequest filterUdiInfoRequest = new FilterUdiInfoRequest();
|
|
|
|
|
* filterUdiInfoRequest.setNameCode(warehouseEntity.getNameCode());
|
|
|
|
|
* List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceService.filterUdiRelevance(filterUdiInfoRequest);
|
|
|
|
|
* if (udiRelevanceEntities != null && udiRelevanceEntities.size() > 1) {
|
|
|
|
|
* warehouseEntity.setRelId(null);
|
|
|
|
|
* warehouseEntity.setStatus(ConstantStatus.ORDER_DETAIL_DI_MUTI);
|
|
|
|
|
* } else if (udiRelevanceEntities == null || udiRelevanceEntities.size() == 0) {
|
|
|
|
|
* warehouseEntity.setRelId(null);
|
|
|
|
|
* warehouseEntity.setStatus(2);
|
|
|
|
|
* } else {
|
|
|
|
|
* warehouseEntity.setStatus(0);
|
|
|
|
|
* warehouseEntity.setRelId(udiRelevanceEntities.get(0).getId() + "");
|
|
|
|
|
* }
|
|
|
|
|
* warehouseService.updateCode(warehouseEntity);
|
|
|
|
|
* }
|
|
|
|
|
* <p>
|
|
|
|
|
* <p>
|
|
|
|
|
* if (orderEntity.getErpFk() != null && !"".equals(orderEntity.getErpFk())) {//已经绑定校验单据号,等待校验
|
|
|
|
|
* orderService.updateOrderStatus(orderEntity.getId(), ConstantStatus.ORDER_STATUS_CHECK);
|
|
|
|
|
* } else {
|
|
|
|
|
* //生成单据详情
|
|
|
|
|
* inoutUtils.generateConstrastDetail(udiInfoService, udiRelevanceService, myErpOrderService, warehouseEntityList);
|
|
|
|
|
* if (bussinessTypeEntity.getThirdSysFk() == null && bussinessTypeEntity.getLocalAction() == null) {//不需要校验
|
|
|
|
|
* checkMutiDi(orderEntity.getId()); //校验一个DI是否绑定多个产品ID
|
|
|
|
|
* orderEntity = orderService.findById(orderEntity.getId());
|
|
|
|
|
* if (orderEntity.getContrastStatus() != ConstantStatus.ORDER_CHECK_FAIL) {
|
|
|
|
|
* orderService.updateOrderStatus(orderEntity.getId(), ConstantStatus.ORDER_STATUS_SUCCESS);
|
|
|
|
|
* invProductsTrService.genInvProducts(orderEntity.getId());
|
|
|
|
|
* }
|
|
|
|
|
* } else {//需要校验,等待校验
|
|
|
|
|
* orderService.updateOrderStatus(orderEntity.getId(), ConstantStatus.ORDER_STATUS_CHECK);
|
|
|
|
|
* }
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* @param orderId
|
|
|
|
|
*/
|
|
|
|
|
//转入正式表后,更换单据状态,等待校验或已完成
|
|
|
|
|
public void transStatus(String orderId) {
|
|
|
|
|
//todo 改成等待校验,选择校验
|
|
|
|
|
OrderEntity orderEntity = orderService.findById(orderId);
|
|
|
|
|
BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(orderEntity.getAction());
|
|
|
|
|
|
|
|
|
|
List<WarehouseEntity> warehouseEntityList = warehouseService.findByReceiptId(orderId);
|
|
|
|
|
myErpOrderService.deleteByOrderId(orderEntity.getId());
|
|
|
|
|
//为所有条码关联基础信息关联表ID
|
|
|
|
@ -400,6 +422,14 @@ public class IoTransInoutService {
|
|
|
|
|
FilterUdiInfoRequest filterUdiInfoRequest = new FilterUdiInfoRequest();
|
|
|
|
|
filterUdiInfoRequest.setNameCode(warehouseEntity.getNameCode());
|
|
|
|
|
List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceService.filterUdiRelevance(filterUdiInfoRequest);
|
|
|
|
|
|
|
|
|
|
//默认或已选中供应商
|
|
|
|
|
String originSupId = checkOriginExitSup(warehouseEntity);
|
|
|
|
|
if (originSupId != null) {
|
|
|
|
|
warehouseEntity.setSupId(originSupId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (udiRelevanceEntities != null && udiRelevanceEntities.size() > 1) {
|
|
|
|
|
warehouseEntity.setRelId(null);
|
|
|
|
|
warehouseEntity.setStatus(ConstantStatus.ORDER_DETAIL_DI_MUTI);
|
|
|
|
@ -408,19 +438,32 @@ public class IoTransInoutService {
|
|
|
|
|
warehouseEntity.setStatus(2);
|
|
|
|
|
} else {
|
|
|
|
|
warehouseEntity.setStatus(0);
|
|
|
|
|
warehouseEntity.setRelId(udiRelevanceEntities.get(0).getId() + "");
|
|
|
|
|
String supId = checkOriginExitSup(warehouseEntity);
|
|
|
|
|
if (supId != null) {
|
|
|
|
|
warehouseEntity.setSupId(supId);
|
|
|
|
|
} else {
|
|
|
|
|
supId = checkInvExitSup(warehouseEntity);
|
|
|
|
|
warehouseEntity.setSupId(supId);
|
|
|
|
|
if (warehouseEntity.getRelId() == null)
|
|
|
|
|
warehouseEntity.setRelId(udiRelevanceEntities.get(0).getId() + "");
|
|
|
|
|
if (originSupId == null) {
|
|
|
|
|
if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_OUT) {
|
|
|
|
|
String supId = null;
|
|
|
|
|
if (originSupId == null) {
|
|
|
|
|
supId = checkExitSup(warehouseEntity.getRelId());
|
|
|
|
|
if (supId == null) {
|
|
|
|
|
supId = checkInvExitSup(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
supId = originSupId;
|
|
|
|
|
if (supId != null) {//&& !supId.equals("MUTI")
|
|
|
|
|
warehouseEntity.setSupId(supId);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
String supId = checkExitSup(warehouseEntity.getRelId());
|
|
|
|
|
if (supId == null) {
|
|
|
|
|
supId = checkInvExitSup(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
warehouseEntity.setSupId(supId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
warehouseService.updateCode(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
String action = orderEntity.getAction();
|
|
|
|
|
BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(action);
|
|
|
|
|
if (!bussinessTypeEntity.isCheckEnable()) {
|
|
|
|
|
orderEntity = orderService.findById(orderEntity.getId());
|
|
|
|
|
unCheckFinish(orderEntity, warehouseEntityList);
|
|
|
|
@ -494,12 +537,10 @@ public class IoTransInoutService {
|
|
|
|
|
|
|
|
|
|
//校验是否自带供应商
|
|
|
|
|
public String checkOriginExitSup(WarehouseEntity warehouseEntity) {
|
|
|
|
|
if (ConstantType.TYPE_PUT.equals(warehouseEntity.getMainAction())) {
|
|
|
|
|
if (warehouseEntity.getSupId() != null && !"".equals(warehouseEntity.getSupId())) {
|
|
|
|
|
return warehouseEntity.getSupId();
|
|
|
|
|
} else if (ConstantType.TYPE_PUT.equals(warehouseEntity.getMainAction())) {
|
|
|
|
|
return warehouseEntity.getFromCorpId();
|
|
|
|
|
} else if (ConstantType.TYPE_OUT.equals(warehouseEntity.getMainAction())) {
|
|
|
|
|
if (warehouseEntity.getSupId() != null && !"".equals(warehouseEntity.getSupId())) {
|
|
|
|
|
return warehouseEntity.getSupId();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
@ -531,21 +572,32 @@ public class IoTransInoutService {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //校验是否存在供应商
|
|
|
|
|
// public String checkExitSup(String relId) {
|
|
|
|
|
// //校验条码关联供应商
|
|
|
|
|
// FilterCompanyProductRelevanceRequest filterCompanyProductRelevanceRequest = new FilterCompanyProductRelevanceRequest();
|
|
|
|
|
// filterCompanyProductRelevanceRequest.setUdiRlIdFk(relId);
|
|
|
|
|
// List<CompanyProductRelevanceEntity> companyProductRelevanceEntities = companyProductRelevanceService.filterCompanyProductRelevance(filterCompanyProductRelevanceRequest);
|
|
|
|
|
// if (companyProductRelevanceEntities != null && companyProductRelevanceEntities.size() == 1) {
|
|
|
|
|
// CompanyProductRelevanceEntity companyProductRelevanceEntity = companyProductRelevanceEntities.get(0);
|
|
|
|
|
// CompanyEntity companyEntity = companyService.findCompany(companyProductRelevanceEntity.getCustomerId());
|
|
|
|
|
// return companyEntity.getUnitIdFk();
|
|
|
|
|
// } else if (companyProductRelevanceEntities != null && companyProductRelevanceEntities.size() > 1) {
|
|
|
|
|
// return "MUTI"; //绑定多个供应商
|
|
|
|
|
// }
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
//校验是否存在供应商
|
|
|
|
|
public String checkExitSup(String relId) {
|
|
|
|
|
//校验条码关联供应商
|
|
|
|
|
FilterCompanyProductRelevanceRequest filterCompanyProductRelevanceRequest = new FilterCompanyProductRelevanceRequest();
|
|
|
|
|
filterCompanyProductRelevanceRequest.setUdiRlIdFk(relId);
|
|
|
|
|
List<CompanyProductRelevanceEntity> companyProductRelevanceEntities = companyProductRelevanceService.filterCompanyProductRelevance(filterCompanyProductRelevanceRequest);
|
|
|
|
|
if (companyProductRelevanceEntities != null && companyProductRelevanceEntities.size() == 1) {
|
|
|
|
|
CompanyProductRelevanceEntity companyProductRelevanceEntity = companyProductRelevanceEntities.get(0);
|
|
|
|
|
// BasicUnitMaintainEntity companyEntity = basicUnitMaintainService.selectByErpId(companyProductRelevanceEntity.getUnitFk());
|
|
|
|
|
return companyProductRelevanceEntity.getUnitFk();
|
|
|
|
|
} else if (companyProductRelevanceEntities != null && companyProductRelevanceEntities.size() > 1) {
|
|
|
|
|
String unitFk = companyProductRelevanceEntities.get(0).getUnitFk();
|
|
|
|
|
boolean isMuti = false;
|
|
|
|
|
for (CompanyProductRelevanceEntity companyProductRelevanceEntity : companyProductRelevanceEntities) {
|
|
|
|
|
if (!unitFk.equals(companyProductRelevanceEntity.getUnitFk())) {
|
|
|
|
|
isMuti = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isMuti)
|
|
|
|
|
return "MUTI"; //绑定多个供应商
|
|
|
|
|
else
|
|
|
|
|
return unitFk;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void genOrderDetail(List<WarehouseEntity> warehouseEntityList) {
|
|
|
|
|
inoutUtils.generateConstrastDetail(udiInfoService, udiRelevanceService, myErpOrderService, warehouseEntityList);
|
|
|
|
@ -840,11 +892,14 @@ public class IoTransInoutService {
|
|
|
|
|
public StockOrderEntity genStockOrder(OrderEntity orderEntity, BussinessTypeEntity bussinessTypeEntity) {
|
|
|
|
|
//生成业务单据记录
|
|
|
|
|
StockOrderEntity stockOrderEntity = new StockOrderEntity();
|
|
|
|
|
stockOrderEntity.setBillNo(orderEntity.getId());
|
|
|
|
|
stockOrderEntity.setBillNo("ST" + CustomUtil.getId());
|
|
|
|
|
stockOrderEntity.setBillType(bussinessTypeEntity.getLocalAction());//todo
|
|
|
|
|
stockOrderEntity.setBilldate(orderEntity.getActDate());
|
|
|
|
|
stockOrderEntity.setUnitIdFk(orderEntity.getFromCorpId());
|
|
|
|
|
stockOrderEntity.setSourceType(ConstantStatus.ST_SCAN_ADD);
|
|
|
|
|
stockOrderEntity.setCreateUser(orderEntity.getCreateUser());
|
|
|
|
|
stockOrderEntity.setReviewUser(orderEntity.getReviewUser());
|
|
|
|
|
stockOrderEntity.setLocStorageCode(orderEntity.getLocStorageCode());
|
|
|
|
|
stockOrderEntity.setCorpId(orderEntity.getFromCorpId());
|
|
|
|
|
if (bussinessTypeEntity.isSecCheckEnable()) {
|
|
|
|
|
stockOrderEntity.setStatus(ConstantStatus.SORDER_DELIVER);
|
|
|
|
|