@ -2,6 +2,7 @@ package com.foreverwin.mesnac.production.service.impl;
import com.alibaba.fastjson.JSONObject ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils ;
import com.fasterxml.jackson.core.type.TypeReference ;
import com.fasterxml.jackson.databind.ObjectMapper ;
import com.foreverwin.mesnac.common.constant.Constants ;
@ -23,7 +24,9 @@ import com.foreverwin.mesnac.common.util.ERPAPI;
import com.foreverwin.mesnac.common.util.ExceptionUtil ;
import com.foreverwin.mesnac.common.util.StringUtil ;
import com.foreverwin.mesnac.dispatch.model.SfcDispatch ;
import com.foreverwin.mesnac.dispatch.model.UserResource ;
import com.foreverwin.mesnac.dispatch.service.SfcDispatchService ;
import com.foreverwin.mesnac.dispatch.service.UserResourceService ;
import com.foreverwin.mesnac.integration.model.IntegrationLog ;
import com.foreverwin.mesnac.integration.service.IntegrationLogService ;
import com.foreverwin.mesnac.meapi.dto.BomComponentDto ;
@ -44,6 +47,7 @@ import com.foreverwin.modular.core.exception.BaseException;
import com.foreverwin.modular.core.exception.BusinessException ;
import com.foreverwin.modular.core.meext.MEServices ;
import com.foreverwin.modular.core.util.CommonMethods ;
import com.foreverwin.modular.core.util.R ;
import com.sap.me.production.AssembleComponentsRequest ;
import com.sap.me.production.AssemblyComponent ;
import com.sap.me.production.AssemblyDataField ;
@ -57,9 +61,12 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal ;
import java.math.RoundingMode ;
import java.text.SimpleDateFormat ;
import java.time.Duration ;
import java.time.LocalDateTime ;
import java.time.ZoneId ;
import java.util.* ;
import java.util.stream.Collectors ;
@Service
@ -107,6 +114,9 @@ public class PodTemplateServiceImpl implements PodTemplateService {
private ResrceMapper resrceMapper ;
@Autowired
private SfcDispatchService sfcDispatchService ;
@Autowired
private UserResourceService userResourceService ;
@Override
@ -165,9 +175,34 @@ public class PodTemplateServiceImpl implements PodTemplateService {
if ( resultMap = = null ) {
throw new BaseException ( "根据当前资源未找到条码[" + sfc + "]的基本信息!" ) ;
}
if ( resultMap . get ( "EMPLOYEE_DESCRIPTION" ) = = null | | resultMap . get ( "EMPLOYEE_DESCRIPTION" ) . equals ( "" ) || resultMap . get ( "EMPLOYEE" ) = = null | | resultMap . get ( "EMPLOYEE" ) . equals ( "" ) ){
if ( resultMap . get ( "EMPLOYEE_DESCRIPTION" ) = = null | | resultMap . get ( "EMPLOYEE_DESCRIPTION" ) . equals ( "" ) ){
throw new BaseException ( "产品条码[" + sfc + "]的操作人员为空!请联系调度人员维护!" ) ;
}
/ * *
* 派 工 无 操 作 者 员 工 号 补 充 代 码
* /
if ( resultMap . get ( "EMPLOYEE" ) = = null | | resultMap . get ( "EMPLOYEE" ) . equals ( "" ) ) {
//获取操作者
String EMPLOYEE_DESCRIPTION = resultMap . get ( "EMPLOYEE_DESCRIPTION" ) . toString ( ) ;
//员工资源对应关系
List < UserResource > userResourceList = userResourceService . findEnableList ( site , sfcDto . getResrce ( ) , null ) ;
Map < String , List < UserResource > > usMap = userResourceList . stream ( ) . collect ( Collectors . groupingBy ( UserResource : : getUserDescription ) ) ;
List < UserResource > singleUserResourceList = usMap . get ( EMPLOYEE_DESCRIPTION ) ;
if ( CollectionUtils . isNotEmpty ( singleUserResourceList ) ) {
//更新派工单的操作员编号
SfcDispatch sfcDispatch = new SfcDispatch ( ) ;
sfcDispatch . setHandle ( resultMap . get ( "SFC_DISPATCH_DETAIL_BO" ) . toString ( ) ) ;
sfcDispatch . setEmployee ( singleUserResourceList . get ( 0 ) . getUserId ( ) ) ;
sfcDispatchService . updateById ( sfcDispatch ) ;
}
}
//List<Map<String, Object>> substepList = sfcCrossMapper.querySfcStep(site, sfc, operationBySfcBo.getOperation());
List < Map < String , Object > > substepList = new ArrayList < > ( ) ;
resultMap . put ( "SFC_STEP_LIST" , substepList ) ;
@ -270,7 +305,7 @@ public class PodTemplateServiceImpl implements PodTemplateService {
}
@Override
public String sfcComplete ( SfcDto sfcDto , String resrce ) {
public String sfcComplete ( SfcDto sfcDto , String resrce ,String shoporder ) {
String site = CommonMethods . getSite ( ) ;
String operation = sfcDto . getOperation ( ) ;
Operation currentRevisionRef = operationService . getCurrentRevisionRef ( site , operation ) ;
@ -309,6 +344,22 @@ public class PodTemplateServiceImpl implements PodTemplateService {
}
}
}
//相同工序不同SFC相同工单号不能在一分钟之内点完成( 拆单重复吸收原材料)
/ * *
* 1. 查 询
* 2. 比 较 拆 单 后 相 同 工 序 的 最 后 一 个 完 成 时 间
* /
SfcDispatch sfcDispatchDto = sfcDispatchService . findsfcComplete ( site , sfcDto . getStepId ( ) , shoporder ) ;
if ( sfcDispatchDto ! = null ) {
LocalDateTime now = LocalDateTime . now ( ) ;
Duration duration = Duration . between ( sfcDispatchDto . getActualCompleteDate ( ) , now ) ;
long minutes = duration . toMinutes ( ) ; //相差的分钟数
if ( minutes < 1 ) {
throw new BaseException ( "拆单后同一工序不能一分钟内点两次完成!" ) ;
}
}
//物料消耗
materialConsumption ( site , operation , HandleEnum . SFC . getHandle ( site , sfc ) , stepId , resrce ) ;
//专检创建
@ -498,10 +549,8 @@ public class PodTemplateServiceImpl implements PodTemplateService {
struIn . setIsm06 ( workHour ) ;
ins [ 0 ] = struIn ;
TableOfZprodordconfStruInHolder inHolder = new TableOfZprodordconfStruInHolder ( ins ) ;
//返回对象
ZprodordconfStruOut [ ] outs = new ZprodordconfStruOut [ 1 ] ;
ZprodordconfStruOut struOut = new ZprodordconfStruOut ( ) ;
struOut . setAufnr ( ins [ 0 ] . getAufnr ( ) ) ;
struOut . setVornr ( ins [ 0 ] . getVornr ( ) ) ;