|
|
|
@ -4,6 +4,7 @@ import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdOrgExtService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesReworkTaskService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesTemplateService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesAssemblyExtService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNumberRuleMatchDispatchService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
|
|
|
|
@ -111,6 +112,12 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesProduceSnExtService produceSnExtService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesAssemblyExtService mesAssemblyExtService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesProductionAssemblyUniqueRepository mesProductionAssemblyUniqueRepository;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ListPager<MesReworkTask> queryReworkTask(MesReworkTask mesReworkTask, Pager pager) {
|
|
|
|
|
String organizeCode = !StringUtils.isEmpty(mesReworkTask.getOrganizeCode())?mesReworkTask.getOrganizeCode():AuthUtil.getOrganizeCode();
|
|
|
|
@ -208,9 +215,30 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
|
|
|
|
|
if (CollectionUtils.isEmpty(mesProductionAssemblies)) {
|
|
|
|
|
MesPcnException.throwFlowException("装配件信息不存在");
|
|
|
|
|
}
|
|
|
|
|
//装配件是自制件,查询自制件经过的装配件记录
|
|
|
|
|
recursionAssemblySn(mesProductionAssemblies,requestModel);
|
|
|
|
|
|
|
|
|
|
return mesProductionAssemblies;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void recursionAssemblySn(List<MesProductionAssembly> mesProductionAssemblyList,MesReworkTaskRequestModel requestModel){
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(requestModel.getOrganizeCode());
|
|
|
|
|
DdlPreparedPack.getInPackList(mesProductionAssemblyList.stream().map(MesProductionAssembly::getAssemblySn).distinct().collect(Collectors.toList()), "productSn", packBean);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(requestModel.getIsOrigSn(), "isOrigSn", packBean);
|
|
|
|
|
if (!StringUtils.isEmpty(requestModel.getAssemblyPartNo())) {
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(requestModel.getAssemblyPartNo(), "assemblyPartNo", packBean);
|
|
|
|
|
}
|
|
|
|
|
if (!Objects.isNull(requestModel.getAssemblyPartStatus())) {
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(requestModel.getAssemblyPartStatus(), "assemblyStatus", packBean);
|
|
|
|
|
}
|
|
|
|
|
List<MesProductionAssembly> mesProductionAssemblies = mesProductionAssemblyRepository.findByHqlWhere(packBean);
|
|
|
|
|
if(!CollectionUtils.isEmpty(mesProductionAssemblies)){
|
|
|
|
|
recursionAssemblySn(mesProductionAssemblies,requestModel);
|
|
|
|
|
mesProductionAssemblyList.addAll(mesProductionAssemblies);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void reworkSuccess(MesReworkTaskRequestModel requestModel) {
|
|
|
|
|
|
|
|
|
@ -239,6 +267,16 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
|
|
|
|
|
mesReworkTask.setStatus(MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(mesReworkTask,requestModel.getUserName());
|
|
|
|
|
mesReworkTaskRepository.save(mesReworkTask);
|
|
|
|
|
if (!StringUtils.isEmpty(mesReworkTask.getId())){
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(mesReworkTask.getOrganizeCode());
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(mesReworkTask.getId(), "reworkTaskId", packBean);
|
|
|
|
|
MesPartInspection mesPartInspection = mesPartInspectionRepository.getByProperty(packBean);
|
|
|
|
|
if (!StringUtils.isEmpty(mesReworkTask.getId())){
|
|
|
|
|
mesPartInspection.setQmsSync(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(mesPartInspection, requestModel.getUserName());
|
|
|
|
|
mesPartInspectionRepository.update(mesPartInspection);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -321,10 +359,9 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
|
|
|
|
|
|
|
|
|
|
// 需要新增一条替换条码的记录
|
|
|
|
|
MesProductionAssembly mesProductionRepeatAssembly = new MesProductionAssembly();
|
|
|
|
|
BeanUtils.copyProperties(assembly, mesProductionRepeatAssembly);
|
|
|
|
|
BeanUtils.copyProperties(assembly, mesProductionRepeatAssembly,MesPcnExtConstWords.ID);
|
|
|
|
|
mesProductionRepeatAssembly.setAssemblySn(requestModel.getSn());
|
|
|
|
|
mesProductionRepeatAssembly.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_10.getValue());
|
|
|
|
|
mesProductionRepeatAssembly.setId(null);
|
|
|
|
|
mesProductionRepeatAssembly.setIsOrigSn(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
|
|
|
|
mesProductionRepeatAssembly.setFid(UUID .randomUUID().toString());
|
|
|
|
|
ConvertBean.serviceModelInitialize(mesProductionRepeatAssembly,requestModel.getUserName());
|
|
|
|
@ -334,17 +371,14 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
|
|
|
|
|
ConvertBean.serviceModelUpdate(assembly,requestModel.getUserName());
|
|
|
|
|
mesProductionAssemblyRepository.update(assembly);
|
|
|
|
|
// 新装配件记录为已装配
|
|
|
|
|
mesProductionAssemblyRepository.insert(mesProductionRepeatAssembly);
|
|
|
|
|
MesProductionAssembly productionAssembly = mesProductionAssemblyRepository.insert(mesProductionRepeatAssembly);
|
|
|
|
|
//唯一性校验数据更新
|
|
|
|
|
if (MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_30.getValue() == assembly.getMatchType()) {
|
|
|
|
|
saveProductionAssemblyUnique(requestModel, assembly.getAssemblySn(), productionAssembly);
|
|
|
|
|
}
|
|
|
|
|
//自制件更新条码状态
|
|
|
|
|
if(MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_10.getValue() == assembly.getMatchType()){
|
|
|
|
|
List<MesProduceSn> produceSnList = produceSnExtService.getProduceSnList(requestModel.getOrganizeCode(), requestModel.getSn());
|
|
|
|
|
if (CollectionUtils.isEmpty(produceSnList)) MesPcnException.throwFlowException("零件条码[%s]信息不存在!", requestModel.getSn());
|
|
|
|
|
Optional<MesProduceSn> optional = produceSnList.stream().filter(sn->sn.getId().equals(((MesProductionAssemblyContext)context).getProductSnId())).findFirst();
|
|
|
|
|
if (!optional.isPresent()) MesPcnException.throwFlowException("零件条码[%s]信息不存在!", requestModel.getSn());
|
|
|
|
|
// 更新新替换得条码为已装配
|
|
|
|
|
updateNewSn(optional.get(),requestModel.getUserName());
|
|
|
|
|
//更新原条码状态为已拆解
|
|
|
|
|
updateOldSn(assembly);
|
|
|
|
|
updateProductSn(requestModel, assembly, (MesProductionAssemblyContext) context);
|
|
|
|
|
}
|
|
|
|
|
checkResult = false;
|
|
|
|
|
break;
|
|
|
|
@ -359,6 +393,43 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateProductSn(MesReworkTaskRequestModel requestModel, MesProductionAssembly assembly, MesProductionAssemblyContext context) {
|
|
|
|
|
List<MesProduceSn> produceSnList = produceSnExtService.getProduceSnList(requestModel.getOrganizeCode(), requestModel.getSn());
|
|
|
|
|
if (CollectionUtils.isEmpty(produceSnList)) MesPcnException.throwFlowException("零件条码[%s]信息不存在!", requestModel.getSn());
|
|
|
|
|
Optional<MesProduceSn> optional = produceSnList.stream().filter(sn->sn.getId().equals(context.getProductSnId())).findFirst();
|
|
|
|
|
if (!optional.isPresent()) MesPcnException.throwFlowException("零件条码[%s]信息不存在!", requestModel.getSn());
|
|
|
|
|
// 更新新替换得条码为已装配
|
|
|
|
|
updateNewSn(optional.get(), requestModel.getUserName());
|
|
|
|
|
//更新原条码状态为已拆解
|
|
|
|
|
updateOldSn(assembly);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveProductionAssemblyUnique(MesReworkTaskRequestModel requestModel, String assemblySN, MesProductionAssembly productionAssembly) {
|
|
|
|
|
//绑定数据解绑
|
|
|
|
|
saveProductionAssemblyUnique(requestModel, assemblySN);
|
|
|
|
|
//唯一性校验数据保存
|
|
|
|
|
saveProductionAssemblyUnique(productionAssembly);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveProductionAssemblyUnique(MesReworkTaskRequestModel requestModel, String assemblySN) {
|
|
|
|
|
List<MesProductionAssemblyUnique> assemblyUniqueList = mesAssemblyExtService.getProductionAssemblyUniqueList(requestModel.getOrganizeCode(), assemblySN);
|
|
|
|
|
if(!CollectionUtils.isEmpty(assemblyUniqueList)){
|
|
|
|
|
assemblyUniqueList.forEach(t->{
|
|
|
|
|
t.setSystemSyncStatus(CommonEnumUtil.FALSE);
|
|
|
|
|
t.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_20.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(t, requestModel.getUserName());
|
|
|
|
|
});
|
|
|
|
|
mesProductionAssemblyUniqueRepository.saveAll(assemblyUniqueList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveProductionAssemblyUnique(MesProductionAssembly productionAssembly) {
|
|
|
|
|
MesProductionAssemblyUnique productionAssemblyUnique = new MesProductionAssemblyUnique();
|
|
|
|
|
BeanUtils.copyProperties(productionAssembly, productionAssemblyUnique, MesPcnExtConstWords.ID);
|
|
|
|
|
productionAssemblyUnique.setPid(productionAssembly.getId());
|
|
|
|
|
mesProductionAssemblyUniqueRepository.insert(productionAssemblyUnique);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Object getContext(MesReworkTaskRequestModel requestModel, MesProductionAssembly mesProductionAssembly,Map<String,MesWorkCenter> mesWorkCenterMap) {
|
|
|
|
|
if(StringUtils.isEmpty(mesProductionAssembly.getWorkCenterCode())) MesPcnException.throwFlowException("产线代码不存在");
|
|
|
|
|
Object context = null;
|
|
|
|
@ -492,10 +563,9 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
|
|
|
|
|
|
|
|
|
|
// 需要新增一条替换条码的记录
|
|
|
|
|
MesProductionAssembly mesProductionRepeatAssembly = new MesProductionAssembly();
|
|
|
|
|
BeanUtils.copyProperties(mesProductionAssembly, mesProductionRepeatAssembly);
|
|
|
|
|
BeanUtils.copyProperties(mesProductionAssembly, mesProductionRepeatAssembly,MesPcnExtConstWords.ID);
|
|
|
|
|
mesProductionRepeatAssembly.setAssemblySn(sn);
|
|
|
|
|
mesProductionRepeatAssembly.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_10.getValue());
|
|
|
|
|
mesProductionRepeatAssembly.setId(null);
|
|
|
|
|
mesProductionRepeatAssembly.setIsOrigSn(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
|
|
|
|
mesProductionRepeatAssembly.setFid(UUID .randomUUID().toString());
|
|
|
|
|
|
|
|
|
@ -509,7 +579,11 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
|
|
|
|
|
mesProductionAssemblyRepository.update(mesProductionAssembly);
|
|
|
|
|
// 新装配件记录为已装配
|
|
|
|
|
ConvertBean.serviceModelInitialize(mesProductionRepeatAssembly,requestModel.getUserName());
|
|
|
|
|
mesProductionAssemblyRepository.insert(mesProductionRepeatAssembly);
|
|
|
|
|
MesProductionAssembly productionAssembly = mesProductionAssemblyRepository.insert(mesProductionRepeatAssembly);
|
|
|
|
|
//唯一性校验数据更新
|
|
|
|
|
if (MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_30.getValue() == mesProductionAssembly.getMatchType()) {
|
|
|
|
|
saveProductionAssemblyUnique(requestModel, mesProductionAssembly.getAssemblySn(), productionAssembly);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 需要更新NC标记后进入的表明细状态为已处理
|
|
|
|
|