@ -18,6 +18,7 @@ import com.foreverwin.mesnac.common.dto.ScrapDto;
import com.foreverwin.mesnac.common.dto.SfcDispatchDto ;
import com.foreverwin.mesnac.common.dto.SfcDispatchDto ;
import com.foreverwin.mesnac.common.dto.UsrDto ;
import com.foreverwin.mesnac.common.dto.UsrDto ;
import com.foreverwin.mesnac.common.enums.AnomalyConstant ;
import com.foreverwin.mesnac.common.enums.AnomalyConstant ;
import com.foreverwin.mesnac.common.enums.DispatchStatusEnum ;
import com.foreverwin.mesnac.common.enums.HandleEnum ;
import com.foreverwin.mesnac.common.enums.HandleEnum ;
import com.foreverwin.mesnac.common.helper.NextNumberHelper ;
import com.foreverwin.mesnac.common.helper.NextNumberHelper ;
import com.foreverwin.mesnac.common.mapper.MessageMapper ;
import com.foreverwin.mesnac.common.mapper.MessageMapper ;
@ -26,26 +27,36 @@ import com.foreverwin.mesnac.common.model.Message;
import com.foreverwin.mesnac.common.service.* ;
import com.foreverwin.mesnac.common.service.* ;
import com.foreverwin.mesnac.common.util.ActiveMQUtil ;
import com.foreverwin.mesnac.common.util.ActiveMQUtil ;
import com.foreverwin.mesnac.common.util.DateUtil ;
import com.foreverwin.mesnac.common.util.DateUtil ;
import com.foreverwin.mesnac.common.util.ExceptionUtil ;
import com.foreverwin.mesnac.common.util.StringUtil ;
import com.foreverwin.mesnac.common.util.StringUtil ;
import com.foreverwin.mesnac.listener.mapper.UsrMapper ;
import com.foreverwin.mesnac.listener.mapper.UsrMapper ;
import com.foreverwin.mesnac.meapi.dto.NcCodeDto ;
import com.foreverwin.mesnac.meapi.dto.NcCodeDto ;
import com.foreverwin.mesnac.meapi.dto.RouterStepDto ;
import com.foreverwin.mesnac.meapi.dto.SfcDto ;
import com.foreverwin.mesnac.meapi.mapper.* ;
import com.foreverwin.mesnac.meapi.mapper.* ;
import com.foreverwin.mesnac.meapi.model.* ;
import com.foreverwin.mesnac.meapi.model.* ;
import com.foreverwin.mesnac.meapi.service.* ;
import com.foreverwin.mesnac.meapi.service.* ;
import com.foreverwin.mesnac.meapi.util.StringUtils ;
import com.foreverwin.mesnac.meapi.util.StringUtils ;
import com.foreverwin.mesnac.production.dto.SplitSfcDto ;
import com.foreverwin.mesnac.production.mapper.SplitSfcMapper ;
import com.foreverwin.mesnac.production.model.SplitSfc ;
import com.foreverwin.mesnac.production.model.SplitSfc ;
import com.foreverwin.mesnac.production.service.SplitSfcService ;
import com.foreverwin.mesnac.production.service.SplitSfcService ;
import com.foreverwin.mesnac.quality.service.SelfReportService ;
import com.foreverwin.mesnac.quality.service.SelfReportService ;
import com.foreverwin.modular.core.exception.BaseException ;
import com.foreverwin.modular.core.exception.BaseException ;
import com.foreverwin.modular.core.exception.BusinessException ;
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.CommonMethods ;
import com.foreverwin.modular.core.util.FrontPage ;
import com.foreverwin.modular.core.util.FrontPage ;
import com.sap.me.nonconformance.* ;
import com.sap.me.production.SplitSerializeServiceInterface ;
import com.sap.me.production.SplitSfcRequest ;
import org.springframework.beans.BeanUtils ;
import org.springframework.beans.BeanUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.context.i18n.LocaleContextHolder ;
import org.springframework.context.i18n.LocaleContextHolder ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.transaction.annotation.Transactional ;
import java.math.BigDecimal ;
import java.text.SimpleDateFormat ;
import java.text.SimpleDateFormat ;
import java.time.LocalDateTime ;
import java.time.LocalDateTime ;
import java.util.* ;
import java.util.* ;
@ -159,6 +170,15 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Autowired
@Autowired
private UsrMapper usrMapper ;
private UsrMapper usrMapper ;
@Autowired
private SplitSfcMapper splitSfcMapper ;
@Autowired
private RouterStepService routerStepService ;
@Autowired
private CommonService commonService ;
@Override
@Override
public IPage < AbnormalBill > selectPage ( FrontPage < AbnormalBill > frontPage , AbnormalBill abnormalBill ) {
public IPage < AbnormalBill > selectPage ( FrontPage < AbnormalBill > frontPage , AbnormalBill abnormalBill ) {
@ -199,8 +219,17 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
String message = this . generateAbnormalBill ( abnormalBill , abnormalBillDispose , dutyCauseType , dutyType ) ;
String message = this . generateAbnormalBill ( abnormalBill , abnormalBillDispose , dutyCauseType , dutyType ) ;
//获取当前时间
//获取当前时间
LocalDateTime now = LocalDateTime . now ( ) ;
LocalDateTime now = LocalDateTime . now ( ) ;
String site = CommonMethods . getSite ( ) ;
if ( StringUtils . isBlank ( abnormalBill . getStepId ( ) ) ) {
throw new BaseException ( "根据SFC找不到StepId" ) ;
}
if ( ! StringUtils . isBlank ( abnormalBill . getObjectBo ( ) ) ) {
if ( "J" . equals ( abnormalBill . getReportFrom ( ) ) ) {
abnormalBill . setObjectBo ( HandleEnum . INSPECTION_TASK . getHandle ( site , abnormalBill . getObjectBo ( ) ) ) ;
} else if ( "B" . equals ( abnormalBill . getReportFrom ( ) ) ) {
abnormalBill . setObjectBo ( HandleEnum . SELF_REPORT . getHandle ( site , abnormalBill . getObjectBo ( ) ) ) ;
}
}
//生成不良代码和不良代码组,并把它放到hashMap里面, ncCode是存放在异常单里面的ncCode
//生成不良代码和不良代码组,并把它放到hashMap里面, ncCode是存放在异常单里面的ncCode
List < String > ncCode = new ArrayList < > ( ) ;
List < String > ncCode = new ArrayList < > ( ) ;
List < String > ncGroup = new ArrayList < > ( ) ;
List < String > ncGroup = new ArrayList < > ( ) ;
@ -301,7 +330,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
* XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX
* XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX
* /
* /
//发送消息
//发送消息
if ( Constants . NEW . equals ( abnormalBill . getStatus ( ) ) ) {
if ( Constants . NEW . equals ( abnormalBill . getStatus ( ) ) ) {
this . anomalyCreatedAndSendMessage ( abnormalBill , null ) ;
this . anomalyCreatedAndSendMessage ( abnormalBill , null ) ;
@ -321,7 +349,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
List < WorkCenter > workCenterList = workCenterService . selectList ( workCenter ) ;
List < WorkCenter > workCenterList = workCenterService . selectList ( workCenter ) ;
hashMap . put ( "workCenter" , workCenterList ) ;
hashMap . put ( "workCenter" , workCenterList ) ;
/ * *
/ * *
* 发 现 环 节
* 发 现 环 节
* /
* /
@ -434,7 +461,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
String site = CommonMethods . getSite ( ) ;
String site = CommonMethods . getSite ( ) ;
String user = CommonMethods . getUser ( ) ;
String user = CommonMethods . getUser ( ) ;
LocalDateTime now = LocalDateTime . now ( ) ;
LocalDateTime now = LocalDateTime . now ( ) ;
String locale = LocaleContextHolder . getLocale ( ) . getLanguage ( ) ;
abnormalBillDispose . setHandle ( HandleEnum . ABNORMAL_BILL_DISPOSE . getHandle ( site , abnormalBill . getAbnormalNo ( ) ) ) ;
abnormalBillDispose . setHandle ( HandleEnum . ABNORMAL_BILL_DISPOSE . getHandle ( site , abnormalBill . getAbnormalNo ( ) ) ) ;
AbnormalBill abnormalBill1 = abnormalBillMapper . selectById ( HandleEnum . ABNORMAL_BILL . getHandle ( site , abnormalBill . getAbnormalNo ( ) ) ) ;
AbnormalBill abnormalBill1 = abnormalBillMapper . selectById ( HandleEnum . ABNORMAL_BILL . getHandle ( site , abnormalBill . getAbnormalNo ( ) ) ) ;
@ -477,6 +503,8 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalBill . setStatus ( Constants . PROGRAM_CONFIRM ) ;
abnormalBill . setStatus ( Constants . PROGRAM_CONFIRM ) ;
abnormalBill . setProgram ( "true" ) ;
abnormalBill . setProgram ( "true" ) ;
abnormalBillDisposeService . saveOrUpdate ( abnormalBillDispose ) ;
abnormalBillDisposeService . saveOrUpdate ( abnormalBillDispose ) ;
this . saveOrUpdate ( abnormalBill ) ;
this . saveOrUpdate ( abnormalBill ) ;
@ -486,6 +514,34 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
AbnormalBillDispose abnormalBillDispose1 = abnormalBillDisposeMapper . selectById ( abnormalBillDispose . getHandle ( ) ) ;
AbnormalBillDispose abnormalBillDispose1 = abnormalBillDisposeMapper . selectById ( abnormalBillDispose . getHandle ( ) ) ;
abnormalPlanService . saveAbnormalPlan ( abnormalBill2 , abnormalBillDispose1 , now ) ;
abnormalPlanService . saveAbnormalPlan ( abnormalBill2 , abnormalBillDispose1 , now ) ;
}
}
//判断该异常解决方案是否是让步放行、配作,如果是,就调用孙豪的方法
if ( Constants . CONCESSION . equals ( abnormalBillDispose . getAbnormalMethod ( ) ) | |
Constants . MATCH . equals ( abnormalBillDispose . getAbnormalMethod ( ) ) ) {
try {
this . creatInspectionTask ( site , abnormalBill2 . getObjectBo ( ) , abnormalBill2 . getSfc ( ) , abnormalBill2 . getStepId ( ) ) ;
} catch ( Exception e ) {
throw new BaseException ( "createInspectionTask方法报错," + e . getMessage ( ) ) ;
}
} else if ( Constants . REPAIR . equals ( abnormalBillDispose . getAbnormalMethod ( ) ) & & StringUtil . isBlank ( abnormalBillDispose . getResolveShopOrder ( ) ) ) {
Sfc sfc = sfcMapper . selectById ( HandleEnum . SFC . getHandle ( site , abnormalBill2 . getSfc ( ) ) ) ;
if ( sfc . getQty ( ) > Double . parseDouble ( abnormalBill2 . getNcQty ( ) ) ) {
//跳过啥都不做
} else if ( sfc . getQty ( ) = = Double . parseDouble ( abnormalBill2 . getNcQty ( ) ) ) {
//整批返修、批量返修
SfcDto sfcDto = new SfcDto ( ) ;
sfcDto . setSfc ( sfc . getSfc ( ) ) ;
sfcDto . setAbnormalNo ( abnormalBill2 . getAbnormalNo ( ) ) ;
sfcDto . setQty ( sfc . getQty ( ) ) ;
Map map = sfcMapper . findOperationBySfc ( site , sfc . getSfc ( ) ) ;
if ( StringUtils . isBlank ( ( String ) map . get ( "STEP_ID" ) ) ) {
throw new BaseException ( "整批返修失败, 根据该产品条码找不到STEP_ID" ) ;
}
sfcDto . setStepId ( ( String ) map . get ( "STEP_ID" ) ) ;
this . batchRepair ( sfcDto ) ;
}
}
this . anomalyCreatedAndSendMessage ( abnormalBill2 , abnormalBillDispose ) ;
this . anomalyCreatedAndSendMessage ( abnormalBill2 , abnormalBillDispose ) ;
}
}
@ -586,7 +642,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
/ * *
/ * *
* 取 消 异 常 提 报 的 更 新
* 取 消 异 常 提 报 的 更 新
* /
* /
//更新的时候,判断该异常单的状态是否为新建,如果为新建,则可以修改,否则就不能进行修改
//更新的时候,判断该异常单的状态是否为新建,如果为新建,则可以修改,否则就不能进行修改
// AbnormalBill abnormalBill1 = abnormalBillMapper.selectById(abnormalBill.getHandle());
// AbnormalBill abnormalBill1 = abnormalBillMapper.selectById(abnormalBill.getHandle());
// if(abnormalBill1 != null){
// if(abnormalBill1 != null){
@ -626,7 +681,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
}
}
}
//判断设备异常提报传递的不良代码是否有误
//判断设备异常提报传递的不良代码是否有误
if ( ! StringUtil . isBlank ( abnormalBill . getNcCode ( ) ) & & Constants . ABNORMAL_RESRCE . equals ( abnormalBill . getType ( ) ) ) {
if ( ! StringUtil . isBlank ( abnormalBill . getNcCode ( ) ) & & Constants . ABNORMAL_RESRCE . equals ( abnormalBill . getType ( ) ) ) {
List < String > ncCodes = Arrays . asList ( abnormalBill . getNcCode ( ) . split ( "," ) ) ;
List < String > ncCodes = Arrays . asList ( abnormalBill . getNcCode ( ) . split ( "," ) ) ;
@ -636,7 +690,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
}
}
}
/ * *
/ * *
* 判 断 SFC , 设 备 异 常 提 交 , sfc 可 以 为 空 , 质 量 异 常 提 报 sfc 和 物 料 编 号 其 中 一 个 不 能 为 空
* 判 断 SFC , 设 备 异 常 提 交 , sfc 可 以 为 空 , 质 量 异 常 提 报 sfc 和 物 料 编 号 其 中 一 个 不 能 为 空
* 设 备 编 号
* 设 备 编 号
@ -725,7 +778,11 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
if ( abnormalBillList . size ( ) > = 1 ) {
if ( abnormalBillList . size ( ) > = 1 ) {
throw BusinessException . build ( abnormalType + "有未处理完成的产品条码( SFC) " ) ;
throw BusinessException . build ( abnormalType + "有未处理完成的产品条码( SFC) " ) ;
}
}
//根据sfc找出STEP_ID
//判断不良品数量是否大于SFC的数量
Sfc sfc = sfcMapper . selectById ( HandleEnum . SFC . getHandle ( site , abnormalBill . getSfc ( ) ) ) ;
if ( Integer . parseInt ( abnormalBill . getNcQty ( ) ) > sfc . getQty ( ) ) {
throw BusinessException . build ( "质量异常提报的不良品数量不能大于SFC的数量, SFC的数量为:" + sfc . getQty ( ) ) ;
}
}
}
@ -1195,6 +1252,83 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
return abnormalBillMapper . getAbnormalByConditional ( page , paramMap , keyword ) ;
return abnormalBillMapper . getAbnormalByConditional ( page , paramMap , keyword ) ;
}
}
/ * *
* @param sfcDto 以 下 是 传 递 的 参 数
* sfc
* abnormalNo
* qty
* stepId
* * /
@Override
public void batchRepair ( SfcDto sfcDto ) {
String site = CommonMethods . getSite ( ) ;
String sfc = sfcDto . getSfc ( ) ;
String abnormalNo = sfcDto . getAbnormalNo ( ) ;
String handle = HandleEnum . SFC . getHandle ( site , sfc ) ;
BigDecimal splitQty = new BigDecimal ( sfcDto . getQty ( ) ) ;
//根据sfc找工单等信息
SfcDto sfcData = splitSfcMapper . getSfcData ( handle ) ;
String operation = sfcData . getOperation ( ) ;
if ( sfcData = = null ) {
throw new BaseException ( "未找到产品条码信息" ) ;
}
SfcDispatchDto sfcDispatchDto = new SfcDispatchDto ( ) ;
sfcDispatchDto . setSite ( site ) ;
sfcDispatchDto . setSfc ( sfc ) ;
sfcDispatchDto . setStepId ( sfcData . getStepId ( ) ) ;
SfcDispatchDto sfcDispatchBySfc = sfcDispatchCommonService . findSfcDispatchBySfc ( sfcDispatchDto ) ;
if ( sfcDispatchBySfc . equals ( DispatchStatusEnum . CANCEL . getCode ( ) ) ) {
throw new BaseException ( "产品已取消派工" ) ;
}
//查询质量异常记录数量 处置工艺路线及不良代码
SplitSfcDto splitSfcDto = splitSfcMapper . getAbnormalQty ( site , sfc , operation , abnormalNo ) ;
String routerBo = splitSfcDto . getRouterBo ( ) ;
String ncCode = splitSfcDto . getNcCode ( ) ;
String [ ] splitNcCode = ncCode . split ( "," ) ;
SplitSfcRequest splitSfcRequest = new SplitSfcRequest ( ) ;
try {
SplitSerializeServiceInterface splitService = MEServices . create ( "com.sap.me.production" , "SplitSerializeService" , site ) ;
NCProductionServiceInterface ncProductionService = MEServices . create ( "com.sap.me.nonconformance" , "NCProductionService" , site ) ;
//记录不合格
CreateNCRequest createNCRequest = new CreateNCRequest ( ) ;
createNCRequest . setQty ( splitQty ) ;
createNCRequest . setSfcRef ( HandleEnum . SFC . getHandle ( site , sfc ) ) ;
ProductionContext productionContext = new ProductionContext ( ) ;
StepIdentifier stepIdentifier = new StepIdentifier ( ) ;
stepIdentifier . setStepId ( sfcData . getStepId ( ) ) ;
stepIdentifier . setOperationId ( sfcData . getOperation ( ) ) ;
productionContext . setStepIdentifier ( stepIdentifier ) ;
productionContext . setResourceRef ( commonService . getResrceByOperation ( sfcData . getOperation ( ) ) ) ;
createNCRequest . setProdCtx ( productionContext ) ;
createNCRequest . setNcCodeRef ( HandleEnum . NC_CODE . getHandle ( site , splitNcCode [ 0 ] ) ) ;
ncProductionService . createNC ( createNCRequest ) ;
//不合格处置特殊工艺路线
DispositionMultipleSfcsRequest dispositionSfcsRequest = new DispositionMultipleSfcsRequest ( ) ;
List < String > sfcs = new ArrayList < > ( ) ;
sfcs . add ( HandleEnum . SFC . getHandle ( site , sfc ) ) ;
dispositionSfcsRequest . setSfcs ( sfcs ) ;
dispositionSfcsRequest . setBypassStepValidation ( true ) ;
DispositionSelection dispositionSelection = new DispositionSelection ( ) ;
Router maxRevisionRouter = routerService . getMaxRevisionRouter ( site , StringUtil . trimHandle ( routerBo ) ) ;
dispositionSelection . setRouterRef ( maxRevisionRouter . getHandle ( ) ) ;
dispositionSfcsRequest . setDispositionSelection ( dispositionSelection ) ;
dispositionSfcsRequest . setProdCtx ( new ProductionContext ( ) ) ;
ncProductionService . dispositionMultipleSfcs ( dispositionSfcsRequest ) ;
List < RouterStepDto > routerOperationByRouterBo = routerStepService . findRouterOperationByRouterBo ( site , maxRevisionRouter . getHandle ( ) ) ;
if ( routerOperationByRouterBo . isEmpty ( ) ) {
throw new BaseException ( "处置工艺路线没有步骤" ) ;
}
sfcDispatchCommonService . saveSplitSfcDispatch ( site , CommonMethods . getUser ( ) , "A" , sfcData . getShopOrder ( ) , sfc , operation , sfcDispatchBySfc . getStepId ( ) , sfc , maxRevisionRouter . getHandle ( ) , sfcData . getStepSequence ( ) ) ;
} catch ( Exception e ) {
ExceptionUtil . throwException ( e ) ;
}
}
@Override
@Override
public Map < String , String > jgProductionIsScrap ( String abnormalNo , String site , String sfc ) {
public Map < String , String > jgProductionIsScrap ( String abnormalNo , String site , String sfc ) {
//查询该sfc在质量异常异常方案是否是报废,如果是, 则大于1
//查询该sfc在质量异常异常方案是否是报废,如果是, 则大于1
@ -1279,7 +1413,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
void creatInspectionTask ( String site , String inspectionTaskBo , String sfc , String stepId ) {
void creatInspectionTask ( String site , String inspectionTaskBo , String sfc , String stepId ) {
InspectionTask byId = inspectionTaskService . getById ( inspectionTaskBo ) ;
InspectionTask byId = inspectionTaskService . getById ( inspectionTaskBo ) ;
InspectionTask newInspectionTask = new InspectionTask ( ) ;
InspectionTask newInspectionTask = new InspectionTask ( ) ;
if ( StringUtil . notBlank ( inspectionTaskBo ) ) {
if ( StringUtil . notBlank ( inspectionTaskBo ) ) {
if ( byId = = null ) {
if ( byId = = null ) {
throw new BaseException ( "不存在的专检任务" ) ;
throw new BaseException ( "不存在的专检任务" ) ;