@ -29,6 +29,8 @@ import com.foreverwin.mesnac.meapi.mapper.*;
import com.foreverwin.mesnac.meapi.model.* ;
import com.foreverwin.mesnac.meapi.service.* ;
import com.foreverwin.mesnac.meapi.util.StringUtils ;
import com.foreverwin.mesnac.production.model.SplitSfc ;
import com.foreverwin.mesnac.production.service.SplitSfcService ;
import com.foreverwin.mesnac.quality.service.SelfReportService ;
import com.foreverwin.modular.core.exception.BaseException ;
import com.foreverwin.modular.core.exception.BusinessException ;
@ -140,7 +142,10 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
private DataFieldListMapper dataFieldListMapper ;
@Autowired
private AbnormalCauseMapper abnormalCauseMapper ; ;
private AbnormalCauseMapper abnormalCauseMapper ;
@Autowired
private SplitSfcService splitSfcService ;
@ -1144,19 +1149,84 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
@Override
public boolean jgProductionIsScrap ( String site, String sfc ) {
public Map < String , String > jgProductionIsScrap ( String abnormalNo, String site, String sfc ) {
//查询该sfc在质量异常异常方案是否是报废,如果是, 则大于1
Integer num = abnormalBillMapper . findAbnormalMethodBySFC ( site , sfc ) ;
return num < = 0 ;
String abnormalBo = null ;
if ( ! StringUtils . isBlank ( abnormalNo ) ) {
abnormalBo = HandleEnum . ABNORMAL_BILL . getHandle ( site , abnormalNo ) ;
}
return abnormalBillMapper . findAbnormalMethodBySFC ( site , abnormalBo , sfc ) ;
}
@Override
public List < ScrapDto > getScrapDtoBysfc ( String site , String sfc ) {
//判断该产品条码是否已经报废
if ( this . jgProductionIsScrap ( site , sfc ) ) {
public List < ScrapDto > getScrapDtoBysfc ( String abnormalNo , String site , String sfc ) {
if ( StringUtil . isBlank ( site ) ) {
site = CommonMethods . getSite ( ) ;
}
//根据用户提报上来的sfc和异常单查找主SFC
Map < String , String > map = this . jgProductionIsScrap ( abnormalNo , site , sfc ) ;
String mainSfc = null ;
String abnormalBo = null ;
if ( map ! = null ) {
mainSfc = map . get ( "SFC" ) ;
abnormalBo = map . get ( "HANDLE" ) ;
}
List < SplitSfc > splitSfcs = null ;
SplitSfc splitSfc = new SplitSfc ( ) ;
splitSfc . setSite ( site ) ;
//判断能否找到该主sfc。
if ( StringUtil . isBlank ( mainSfc ) ) {
//判断该用户提报上来的sfc是否为空
if ( StringUtil . isBlank ( sfc ) ) {
throw new BaseException ( "该异常单下没有报废的产品条码" ) ;
}
//如果不为空, 则判断根据这个sfc能从Z_SPLIT_SFC表中查找到主SFC吗, 然后在判断主SFC是否已经报废
splitSfc . setSplitSfc ( sfc ) ;
splitSfcs = splitSfcService . selectList ( splitSfc ) ;
if ( splitSfcs . size ( ) > 0 ) {
Map < String , String > map1 = this . jgProductionIsScrap ( abnormalNo , site , splitSfcs . get ( 0 ) . getSfc ( ) ) ;
mainSfc = map1 . get ( "SFC" ) ;
abnormalBo = map1 . get ( "HANDLE" ) ;
} else {
if ( ! StringUtil . isBlank ( sfc ) & & ! StringUtil . isBlank ( abnormalNo ) ) {
throw new BaseException ( "该异常单下的产品条码不是报废" ) ;
}
throw new BaseException ( "该产品条码的异常方案不是报废" ) ;
}
} else if ( StringUtil . isBlank ( sfc ) ) {
//根据异常单找到了主sfc, 并且sfc参数为空, 找到异常单主sfc下拆分的次sfc
splitSfc . setSfc ( mainSfc ) ;
splitSfcs = splitSfcService . selectList ( splitSfc ) ;
}
List < ScrapDto > scrapDtoBySfc = abnormalBillMapper . findScrapDtoBySfc ( site , mainSfc , splitSfcs ) ;
//如果用户提报上来的sfc不为空, 并且不是主sfc, 则把主sfc从scrapDtoBySfc去掉
if ( ! StringUtil . isBlank ( sfc ) & & ! sfc . equals ( mainSfc ) ) {
for ( int i = 0 ; i < scrapDtoBySfc . size ( ) ; i + + ) {
if ( scrapDtoBySfc . get ( i ) . getSfc ( ) . equals ( mainSfc ) ) {
scrapDtoBySfc . remove ( scrapDtoBySfc . get ( i ) ) ;
continue ;
}
}
}
if ( scrapDtoBySfc . size ( ) < = 0 ) {
throw new BaseException ( "该产品条码的异常方案不是报废" ) ;
}
List < ScrapDto > scrapDtoBySfc = abnormalBillMapper . findScrapDtoBySfc ( site , sfc ) ;
//查找到责任人,放到表里
AbnormalBillDispose abnormalBillDispose = new AbnormalBillDispose ( ) ;
abnormalBillDispose . setAbnormalBillBo ( abnormalBo ) ;
List < AbnormalBillDispose > abnormalBillDisposes = abnormalBillDisposeService . selectList ( abnormalBillDispose ) ;
if ( abnormalBillDisposes . size ( ) > 0 ) {
for ( int i = 0 ; i < scrapDtoBySfc . size ( ) ; i + + ) {
scrapDtoBySfc . get ( i ) . setDutyUser ( abnormalBillDisposes . get ( 0 ) . getPrincipalUser ( ) ) ;
}
}
return scrapDtoBySfc ;
}