@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.gaotao.common.exception.XJException ;
import com.gaotao.common.utils.HttpUtils ;
import com.gaotao.modules.api.entity.issueAndReturnVo.IssueShopOrderDto ;
import com.gaotao.modules.api.entity.issueAndReturnVo.MaterialRequisitionVo ;
import com.gaotao.modules.api.service.IfsApiIssueAndReturnService ;
import com.gaotao.modules.handlingunit.entity.HandlingUnit ;
import com.gaotao.modules.notify.entity.SOIssueNotifyHeader ;
@ -26,6 +27,7 @@ import com.gaotao.modules.trans.service.TransNoControlService;
import com.gaotao.modules.handlingunit.service.HandlingUnitService ;
import com.gaotao.modules.warehouse.service.InventoryStockService ;
import io.jsonwebtoken.lang.Maps ;
import lombok.extern.slf4j.Slf4j ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Value ;
import org.springframework.stereotype.Service ;
@ -38,6 +40,7 @@ import java.util.stream.Collectors;
/ * *
* 生产发料服务实现
* /
@Slf4j
@Service
public class ProductionIssueServiceImpl implements ProductionIssueService {
@ -81,57 +84,29 @@ public class ProductionIssueServiceImpl implements ProductionIssueService {
@Override
public List < ShopOrderVo > getWorkOrderInfo ( String workOrderNo , String site ) throws Exception {
Map < String , Object > params = Map . of (
"ifsDBName" , ifsDBName ,
"domainUserID" , domainUserID ,
"ifsSiteID" , site ,
"ifsOrderNo" , workOrderNo ,
"ifsReleaseNo" , "*" ,
"ifsSequenceNo" , "*"
) ;
ObjectMapper objectMapper = new ObjectMapper ( ) ;
String jsonBody = objectMapper . writeValueAsString ( params ) ;
String ifsResponse = HttpUtils . doGetWithBody ( ifsUrl + "ShopOrder" , jsonBody , null ) ;
ObjectMapper mapper = new ObjectMapper ( ) ;
List < ShopOrderVo > shopOrderVos = mapper . readValue ( ifsResponse , new TypeReference < List < ShopOrderVo > > ( ) {
} ) ;
List < ShopOrderVo > orderInfo = ifsApiIssueAndReturnService . getWorkOrderInfo ( workOrderNo , site , "*" , "*" ) ;
Set < String > allowedStatuses = new HashSet < > ( Arrays . asList ( "Released" , "Reserved" , "Started" ) ) ;
List < ShopOrderVo > shopOrderVos = orderInfo . stream ( ) . filter ( item - > allowedStatuses . contains ( item . getObjstate ( ) ) ) . collect ( Collectors . toList ( ) ) ;
return shopOrderVos ;
}
@Override
public List < ShopOrderMaterialVo > getWorkOrderMaterials ( String workOrderNo , String site ) {
public List < ShopOrderMaterialVo > getWorkOrderMaterials ( String workOrderNo , String site ) throws Exception {
/ / 验证工单状态
if ( ! validateWorkOrderStatus ( workOrderNo , site ) ) {
throw new XJException ( "工单状态不允许发料" ) ;
}
try {
Map < String , Object > params = Map . of (
"ifsDBName" , ifsDBName ,
"domainUserID" , domainUserID ,
"ifsSiteID" , site ,
"ifsOrderNo" , workOrderNo ,
"ifsReleaseNo" , "*" ,
"ifsSequenceNo" , "*"
) ;
ObjectMapper objectMapper = new ObjectMapper ( ) ;
String jsonBody = objectMapper . writeValueAsString ( params ) ;
String ifsResponse = HttpUtils . doGetWithBody ( ifsUrl + "ShopOrderMaterial" , jsonBody , null ) ;
ObjectMapper mapper = new ObjectMapper ( ) ;
List < ShopOrderMaterialVo > materialVos = mapper . readValue ( ifsResponse , new TypeReference < List < ShopOrderMaterialVo > > ( ) {
} ) ;
List < ShopOrderMaterialVo > shopOrderMaterialVos = materialVos . stream ( ) . filter ( m - > "Reserve And Backflush" . equals ( m . getReserveIssueMethod ( ) ) ) . collect ( Collectors . toList ( ) ) ;
return shopOrderMaterialVos ;
} catch ( Exception e ) {
throw new XJException ( "获取工单BOM物料列表失败: " + e . getMessage ( ) ) ;
}
List < ShopOrderMaterialVo > materialVos = ifsApiIssueAndReturnService . getShopOrderMaterial ( workOrderNo , site , "*" , "*" ) ;
List < ShopOrderMaterialVo > shopOrderMaterialVos = materialVos . stream ( ) . filter ( m - > "Reserve And Backflush" . equals ( m . getReserveIssueMethod ( ) ) ) . collect ( Collectors . toList ( ) ) ;
return shopOrderMaterialVos ;
}
@Override
@Transactional
public void directIssue ( DirectIssueDto directIssueDto ) {
public void directIssue ( DirectIssueDto directIssueDto ) throws Exception {
/ / 验证工单状态
if ( ! validateWorkOrderStatus ( directIssueDto . getWorkOrderNo ( ) , directIssueDto . getSite ( ) ) ) {
throw new XJException ( "工单状态不允许发料" ) ;
@ -157,6 +132,7 @@ public class ProductionIssueServiceImpl implements ProductionIssueService {
transCommonRequestDto . setWorkOrderNo ( directIssueDto . getWorkOrderNo ( ) ) ;
transCommonRequestDto . setWarehouseId ( directIssueDto . getWarehouseId ( ) ) ;
Double seqNo = 1 . 0 ;
/ / 处理每个选择的物料
for ( WorkOrderMaterialDto material : directIssueDto . getSelectedMaterials ( ) ) {
/ / 验证物料匹配
@ -182,7 +158,8 @@ public class ProductionIssueServiceImpl implements ProductionIssueService {
subDto . setLocationId ( material . getLocationId ( ) ) ;
subDto . setTransQty ( material . getIssueQty ( ) . toString ( ) ) ;
subDto . setDirection ( "-" ) ;
subDto . setWdrNo ( material . getWdrNo ( ) ) ;
subDto . setWdrNo ( material . getWdrNo ( ) = = null ? "*" : material . getWdrNo ( ) ) ;
subDto . setSqeNo ( seqNo ) ;
subList . add ( subDto ) ;
/ * TransDetailDto transDetailDto = new TransDetailDto ( ) ;
@ -226,6 +203,7 @@ public class ProductionIssueServiceImpl implements ProductionIssueService {
productionIssue . setCreatedDate ( new Date ( ) ) ;
productionIssue . setIfsStatus ( "PENDING" ) ;
issueList . add ( productionIssue ) ; * /
seqNo + + ;
}
transCommonRequestDto . setSubList ( subList ) ;
List < TransDetail > out = transHeaderService . genTransAndChangeInventoryStock ( transCommonRequestDto , "OUT" ) ;
@ -244,11 +222,12 @@ public class ProductionIssueServiceImpl implements ProductionIssueService {
issueShopOrderDto . setIfsWDRNo ( issue . getWdrNo ( ) ) ;
issueShopOrderDto . setIfsSerialNo ( "*" ) ;
issueShopOrderDto . setIfsTransQty ( issue . getTransQty ( ) ) ;
ifsApiIssueAndReturnService . addShopOrderManualIssue ( issueShopOrderDto ) ;
String s = ifsApiIssueAndReturnService . addShopOrderManualIssue ( issueShopOrderDto ) ;
log . info ( "IFS发料错误" , s ) ;
if ( ! "IFSUpdated" . equals ( s ) ) {
throw new Exception ( "IFS发料失败" ) ;
}
}
/ / TODO 调用打印接口
}
@Override