修正采购登记的行收货数量不对bug
This commit is contained in:
parent
398930cbc8
commit
4eb135a070
@ -11,7 +11,6 @@ import com.foreverwin.iep.integration.handler.def.sap.ZmmMesChargCreate1Service;
|
||||
import com.foreverwin.iep.integration.service.RegisterDocumentService;
|
||||
import com.foreverwin.iep.prd.entity.CustomFields;
|
||||
import com.foreverwin.iep.prd.entity.Item;
|
||||
import com.foreverwin.iep.prd.feign.RemoteItemService;
|
||||
import com.foreverwin.iep.prd.mapper.CustomFieldsMapper;
|
||||
import com.foreverwin.iep.prd.mapper.ItemMapper;
|
||||
import com.foreverwin.iep.qms.dto.QmsQcPlanTargetDTO;
|
||||
@ -22,7 +21,6 @@ import com.foreverwin.mom.common.security.util.SecurityUtils;
|
||||
import com.foreverwin.mom.wms.api.feign.RemotePoService;
|
||||
import com.foreverwin.mom.wms.entity.DocumentDetailed;
|
||||
import com.foreverwin.mom.wms.util.StringUtils;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@ -64,12 +62,12 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
String itemNo = documentDetail.getMatnr();
|
||||
// 判断物料是否需要从SAP那边获取批次号
|
||||
Item itemInfo = findItemCurrentRevision(itemNo, site);
|
||||
if(itemInfo==null){
|
||||
throw BusinessException.build("物料"+itemNo+"未有当前版本");
|
||||
if (itemInfo == null) {
|
||||
throw BusinessException.build("物料" + itemNo + "未有当前版本");
|
||||
}
|
||||
documentDetail.setItemBo(itemInfo.getHandle());
|
||||
String fieldValue = findCustomFieldByItem(itemInfo.getHandle(), "BATCH_MANAGEMENT",site);
|
||||
if("X".equals(fieldValue)){
|
||||
String fieldValue = findCustomFieldByItem(itemInfo.getHandle(), "BATCH_MANAGEMENT", site);
|
||||
if ("X".equals(fieldValue)) {
|
||||
// 物料自定义字段:是否批次管理,若是存值X则调用SAP批次申请接口,若存值为空则批次写值YYYYMMDD作为批次
|
||||
if (itemMap.get(itemNo) == null) {
|
||||
itemMap.put(itemNo, 1);
|
||||
@ -83,13 +81,14 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
String result = invokeResponse.getResult();
|
||||
if ("E".equals(result)) {
|
||||
throw BusinessException.build("获取物料的sap批次失败");
|
||||
}else {
|
||||
} else {
|
||||
JSONArray jsonArray = null;
|
||||
if(!"X".equals(result)){
|
||||
if (!"X".equals(result)) {
|
||||
jsonArray = JSONArray.parseArray(invokeResponse.getMessageContent());
|
||||
}
|
||||
List<DocumentDetailed> newDocumentList = new ArrayList<>();
|
||||
for (DocumentDetailed documentDetail : zwDocumentDetailList) {
|
||||
documentDetail.setExternalSeq((documentDetail.getExternalSeq() / 10) * 10);
|
||||
// 增加校验判断是否要做IQC
|
||||
List<QmsQcPlanTargetDTO> qmsQcPlanTargetDTOS = remoteQmsQcPlanTargetService.getByTargetBo(documentDetail.getItemBo()).getData();
|
||||
documentDetail.setIqcStatus(qmsQcPlanTargetDTOS.isEmpty() ? "1001" : "1004");
|
||||
@ -97,7 +96,7 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
documentDetail.setTargetWarehouse(documentDetail.getStoragLocation());
|
||||
String itemNo = documentDetail.getMatnr();
|
||||
// 使用迭代器进行遍历和移除
|
||||
if(jsonArray!=null){
|
||||
if (jsonArray != null) {
|
||||
Iterator<Object> iterator = jsonArray.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
JSONObject minJson = (JSONObject) iterator.next();
|
||||
@ -108,7 +107,7 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(StringUtils.isEmpty(documentDetail.getBatch())){
|
||||
if (StringUtils.isEmpty(documentDetail.getBatch())) {
|
||||
documentDetail.setBatch(selfBatchNo);
|
||||
}
|
||||
newDocumentList.add(documentDetail);
|
||||
@ -127,7 +126,7 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
// 组装抛送的报完呢
|
||||
JSONArray itemList = assembleFSMM02602(site, newDocumentList);
|
||||
String postingDate = newDocumentList.get(0).getPostingDate();
|
||||
String srcPo = newDocumentList.get(0).getExternalNo()+"-"+newDocumentList.get(0).getExternalSeq();
|
||||
String srcPo = newDocumentList.get(0).getExternalNo() + "-" + newDocumentList.get(0).getExternalSeq();
|
||||
String jsonObjectStr = SapUtil.appendHead(assembleMaterialMsgBody(itemList, postingDate));
|
||||
invokeRequest.setMessageContent(jsonObjectStr);
|
||||
invokeRequest.setStart(nowTime);
|
||||
@ -136,7 +135,7 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
// 呼叫SAP
|
||||
invokeResponse = materialConsumptionService.call(invokeRequest);
|
||||
|
||||
if("S".equals(invokeResponse.getResult())){
|
||||
if ("S".equals(invokeResponse.getResult())) {
|
||||
// 调用远程服务进行单据的保存和记录库存
|
||||
for (DocumentDetailed documentDetail : newDocumentList) {
|
||||
documentDetail.setMaterialDocument(invokeResponse.getMessageContent());
|
||||
@ -159,10 +158,10 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
@Override
|
||||
@Transactional
|
||||
public void cancelDocumentNo(DocumentDetailed documentDetailed) {
|
||||
String documentNo = documentDetailed.getDocumentNo();
|
||||
String site = TenantContextHolder.getTenantId();
|
||||
remotePoService.cancelDocumentNo(documentDetailed);
|
||||
// @TODO 呼叫SAP
|
||||
String documentNo = documentDetailed.getDocumentNo();
|
||||
String site = TenantContextHolder.getTenantId();
|
||||
remotePoService.cancelDocumentNo(documentDetailed);
|
||||
// @TODO 呼叫SAP
|
||||
}
|
||||
|
||||
private Item findItemCurrentRevision(String itemNo, String site) {
|
||||
@ -171,14 +170,14 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
return itemMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
private String findCustomFieldByItem(String itemBo, String fieldName,String site) {
|
||||
private String findCustomFieldByItem(String itemBo, String fieldName, String site) {
|
||||
QueryWrapper<CustomFields> queryWrapper = new QueryWrapper<CustomFields>();
|
||||
queryWrapper.lambda().eq(CustomFields::getTableName, "ITEM").eq(CustomFields::getSite, site)
|
||||
.eq(CustomFields::getFieldName, fieldName).eq(CustomFields::getHandle, itemBo);
|
||||
CustomFields customFields = customFieldsMapper.selectOne(queryWrapper);
|
||||
if (customFields == null){
|
||||
if (customFields == null) {
|
||||
return "";
|
||||
}else{
|
||||
} else {
|
||||
return customFields.getFieldValue();
|
||||
}
|
||||
}
|
||||
@ -198,7 +197,7 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
jsonObject.put("INSMK", "1001".equals(detail.getIqcStatus()) ? "" : "X"); // 库存类型
|
||||
jsonObject.put("AUFNR", ""); // 订单号
|
||||
jsonObject.put("EBELN", detail.getExternalNo()); // 采购订单号
|
||||
jsonObject.put("EBELP", (detail.getExternalSeq() / 10) * 10); // 采购凭证的项目编号
|
||||
jsonObject.put("EBELP", detail.getExternalSeq()); // 采购凭证的项目编号
|
||||
jsonObject.put("MENGE", detail.getApplicationsQuantity()); // 数量
|
||||
jsonObject.put("MEINS", detail.getUnitOfMeasure()); // 基本计量单位
|
||||
jsonObject.put("ERFMG", detail.getApplicationsQuantity()); // 以录入项单位表示的数量
|
||||
@ -262,7 +261,7 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
|
||||
public InvokeResponse assembleInvokeRequest(String site, Map<String, Integer> items, InvokeRequest invokeRequest) {
|
||||
InvokeResponse invokeResponse = new InvokeResponse(invokeRequest);
|
||||
if(items.size()>0){
|
||||
if (items.size() > 0) {
|
||||
// 呼叫ERP获取批次号
|
||||
LocalDateTime nowLocalDateTime = LocalDateTime.now();
|
||||
String nowTime = nowLocalDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
@ -280,7 +279,7 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
invokeRequest.setKeyValue(items.toString());
|
||||
invokeRequest.setRetry(false);
|
||||
invokeResponse = zmmMesChargCreate1Service.call(invokeRequest);
|
||||
}else{
|
||||
} else {
|
||||
invokeResponse.setResult("X");
|
||||
}
|
||||
return invokeResponse;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user