| | |
| | | package org.jeecg.modules.wms.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.aspect.annotation.ApiLog; |
| | | import org.jeecg.common.constant.ApiLogCategoryEnum; |
| | | import org.jeecg.modules.base.entity.LineSideWarehouse; |
| | | import org.jeecg.modules.base.service.ILineSideWarehouseService; |
| | | import org.jeecg.modules.lsw.entity.LswMaterialInbound; |
| | | import org.jeecg.modules.lsw.service.ILswMaterialInboundService; |
| | | import org.jeecg.modules.mes.entity.MesMaterialTransferRequest; |
| | | import org.jeecg.modules.mes.enums.MaterialTransferRequestStatus; |
| | | import org.jeecg.modules.mes.service.IMesMaterialTransferRequestService; |
| | | import org.jeecg.modules.wms.dto.WSResponse; |
| | | import org.jeecg.modules.wms.request.ReceiveWMSScanItemList; |
| | | import org.jeecg.modules.wms.request.WMSWebServiceSendItem; |
| | | import org.jeecg.modules.wms.service.MESWebServiceSoap; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.jws.WebMethod; |
| | | import javax.jws.WebParam; |
| | |
| | | import javax.jws.WebService; |
| | | import javax.xml.ws.RequestWrapper; |
| | | import javax.xml.ws.ResponseWrapper; |
| | | import java.math.BigDecimal; |
| | | |
| | | |
| | | @Slf4j |
| | |
| | | @WebService(name = "MESWebServiceSoap", targetNamespace = "http://xhj008.server.webservice.com", endpointInterface = "org.jeecg.modules.wms.service.MESWebServiceSoap") |
| | | public class MESWebServiceSoapImpl implements MESWebServiceSoap { |
| | | |
| | | @Autowired |
| | | private IMesMaterialTransferRequestService materialTransferRequestService; |
| | | @Autowired |
| | | private ILineSideWarehouseService lineSideWarehouseService; |
| | | @Autowired |
| | | private ILswMaterialInboundService materialInboundService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @WebMethod(operationName = "ReceiveWMSScanItemList", action = "http://xhj008.server.webservice.com/ReceiveWMSScanItemList") |
| | | @RequestWrapper(localName = "ReceiveWMSScanItemList", targetNamespace = "http://xhj008.server.webservice.com/", className = "ReceiveWMSScanItemList") |
| | | @ResponseWrapper(localName = "ReceiveWMSScanItemListResponse", targetNamespace = "http://xhj008.server.webservice.com/", className = "ReceiveWMSScanItemListResponse") |
| | | @WebResult(name = "ReceiveWMSScanItemListResult", targetNamespace = "http://xhj008.server.webservice.com/") |
| | | @ApiLog(apiName = "接收WMS的移库信息(ReceiveWMSScanItemList(MES)", apiCategory = ApiLogCategoryEnum.WMS) |
| | | public WSResponse receiveWMSScanItemList(@WebParam(name = "ReceiveWMSScanItemList", targetNamespace = "http://xhj008.server.webservice.com/") ReceiveWMSScanItemList request) { |
| | | log.error("11111111111"); |
| | | WSResponse response = new WSResponse(); |
| | | response.setErrorCode("-1"); |
| | | response.setErrorDesc("我时结果集"); |
| | | if (request == null || CollectionUtil.isEmpty(request.getWmsWebServiceSendItemList())) { |
| | | response.setErrorCode("N"); |
| | | response.setErrorDesc("传入的参数为空!"); |
| | | return response; |
| | | } |
| | | String errorCode = "N"; |
| | | int errorCount = 0; |
| | | int successCount = 0; |
| | | StringBuilder errorMsg = new StringBuilder(); |
| | | for (WMSWebServiceSendItem item : request.getWmsWebServiceSendItemList()) { |
| | | if (StringUtils.isNotBlank(item.getReservationOrder())) { |
| | | //物料拉动回调 |
| | | MesMaterialTransferRequest transferRequest = materialTransferRequestService.queryByReservationCode(item.getReservationOrder()); |
| | | if (transferRequest == null) { |
| | | errorCount++; |
| | | errorMsg.append("根据预留号[").append(item.getReservationOrder()).append("]未找到物料拉动单!"); |
| | | continue; |
| | | } |
| | | LineSideWarehouse warehouse = lineSideWarehouseService.getById(transferRequest.getTargetWarehouseId()); |
| | | if(warehouse == null || !warehouse.getWarehouseCode().equals(item.getDestSection())) { |
| | | errorCount++; |
| | | errorMsg.append("线边库[").append(item.getDestSection()).append("]未找到!"); |
| | | continue; |
| | | } |
| | | if(!transferRequest.getMaterialNumber().equals(item.getSkuCode())) { |
| | | errorCount++; |
| | | errorMsg.append("物料编号[").append(item.getSkuCode()).append("]不匹配!"); |
| | | continue; |
| | | } |
| | | if(StringUtils.isBlank(item.getTrackLot())) { |
| | | errorCount++; |
| | | errorMsg.append("批次号[").append(item.getTrackLot()).append("]不能为空!"); |
| | | continue; |
| | | } |
| | | transferRequest.setRequestStatus(MaterialTransferRequestStatus.CHECKED_IN.name()); |
| | | //计算实际拉动数量 |
| | | BigDecimal actualQuantity = transferRequest.getActualQuantity() == null ? item.getQuantity() : transferRequest.getActualQuantity().add(item.getQuantity()); |
| | | transferRequest.setActualQuantity(actualQuantity); |
| | | |
| | | //添加入库信息 |
| | | LswMaterialInbound inbound = new LswMaterialInbound(); |
| | | inbound.setWarehouseId(transferRequest.getTargetWarehouseId()); |
| | | inbound.setReceiver("WMS"); |
| | | inbound.setMaterialNumber(transferRequest.getMaterialNumber()); |
| | | inbound.setMaterialName(transferRequest.getMaterialName()); |
| | | inbound.setBatchNumber(item.getTrackLot()); |
| | | inbound.setQuantity(item.getQuantity()); |
| | | inbound.setFactoryId(warehouse.getFactoryId()); |
| | | boolean b = materialInboundService.inboundMaterial(inbound); |
| | | if(!b) { |
| | | errorCount++; |
| | | errorMsg.append("预留号[").append(item.getReservationOrder()).append("]入库失败!"); |
| | | continue; |
| | | } |
| | | //更新物料拉动单 |
| | | materialTransferRequestService.updateById(transferRequest); |
| | | } else if (StringUtils.isNotBlank(item.getAlign())) { |
| | | //移库单回调 |
| | | } |
| | | } |
| | | return response; |
| | | } |
| | | } |