非排序 返工拆解流程开发

tags/yfai-pcn-ext-v2.3
jun 8 months ago
parent c71f0e983a
commit e8395e2062

@ -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) {
@ -321,10 +349,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 +361,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 +383,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 +553,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 +569,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

@ -8,6 +8,7 @@ import cn.estsh.i3plus.ext.mes.pcn.apiservice.dao.IMesNcProcessingDao;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingInputModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingPartAndLotModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
@ -37,6 +38,7 @@ import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@ -384,6 +386,7 @@ public class MesNcProcessingService implements IMesNcProcessingService {
reworkTask.setPartInspectionId(model.getPartInspection().getId());
reworkTask.setOrganizeCode(org);
reworkTask.setResponsibleParty(model.getOnlyPerson());
reworkTask.setDisassembleType(disassembleType(model, org, sn));
reworkTask.setLotNo(model.getPartInspection().getLotNo());
reworkTask.setType(model.getPartInspection().getSourceType());
ConvertBean.serviceModelInitialize(reworkTask, model.getUserName());
@ -476,6 +479,26 @@ public class MesNcProcessingService implements IMesNcProcessingService {
}
private int disassembleType(MesNcProcessingInputModel model, String org, MesProduceSn sn) {
if (MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue() == model.getPartInspection().getSourceType()) {
if (Objects.isNull(sn)) {
throw new ImppBusiException(String.format("【%s】此条码不存在请检查数据", model.getSn()));
}
//产线信息
MesWorkCenter centerDb = prodOrgExtService.getWorkCenterDb(org, sn.getWorkCenterCode());
if (Objects.isNull(centerDb)) {
throw new ImppBusiException(String.format("产线【%s】信息不存在请检查数据", sn.getWorkCenterCode()));
}
//拆解类型
if (MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue() == centerDb.getCenterType()) {
return MesExtEnumUtil.REWORK_TASK_DISASSEMBLE_TYPE.SORT_DISASSEMBLE.getValue();
} else if (MesExtEnumUtil.WORK_CENTER_TYPE.NOSORT.getValue() == centerDb.getCenterType()) {
return MesExtEnumUtil.REWORK_TASK_DISASSEMBLE_TYPE.NOSORT_DISASSEMBLE.getValue();
}
}
return MesPcnExtConstWords.ZERO;
}
private MesProduceSn checkProduceSn(String serialNumber, String org) {
//根据扫描的条码查询条码是否存在
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);

Loading…
Cancel
Save