|
|
|
@ -203,30 +203,17 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public int downProOrderWorkorderByWorkorderIds(String[] workorderIds) {
|
|
|
|
|
List<String> ids = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
List<ProOrderWorkorder> workorders = proOrderWorkorderMapper.getWorkOrderByIds(workorderIds);
|
|
|
|
|
for (ProOrderWorkorder workorder : workorders) {
|
|
|
|
|
//关联工艺
|
|
|
|
|
if (StringUtils.isNotBlank(workorder.getRouteCode())) {
|
|
|
|
|
List<ProWorkorderProcessDetail> workDetails = proWorkorderProcessDetailMapper.getWorkOrderDetailsByRouteCode(workorder);
|
|
|
|
|
if (!CollectionUtils.isEmpty(workDetails)) {
|
|
|
|
|
workDetails.forEach(str -> {
|
|
|
|
|
str.setRecordId(IdUtils.fastSimpleUUID());
|
|
|
|
|
str.setWorkorderId(workorder.getWorkorderId());
|
|
|
|
|
str.setStatus("s0");//未执行
|
|
|
|
|
str.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
str.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
str.setFactoryCode(workorder.getFactoryCode());
|
|
|
|
|
});
|
|
|
|
|
proWorkorderProcessDetailMapper.addWorkOrderDetails(workDetails);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<SapCreateOrder> sapList = null;//回传给sap的工单
|
|
|
|
|
//如果是白坯生成备料单
|
|
|
|
|
for (String workorderId : workorderIds) {
|
|
|
|
|
ProOrderWorkorder whiteOrder = proOrderWorkorderMapper.selectProOrderWorkorderByWorkorderId(workorderId);
|
|
|
|
|
|
|
|
|
|
if (whiteOrder != null && "white".equals(whiteOrder.getProdType())) {//是白坯订单,自主生成领料单;
|
|
|
|
|
//备(领)料明细
|
|
|
|
|
ProWetMaterialPlanDetail planDetail = proWetMaterialPlanDetailMapper.getWetInfo(workorderId);
|
|
|
|
|
if(planDetail != null){
|
|
|
|
|
//备(领)料主单
|
|
|
|
|
MesPrepareDTO mesPrepare = new MesPrepareDTO();
|
|
|
|
|
BeanUtils.copyBeanProp(mesPrepare, whiteOrder);
|
|
|
|
@ -237,24 +224,26 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
mesPrepare.setStatus("L0");//待确认
|
|
|
|
|
proOrderWorkorderMapper.createPrepare(mesPrepare);
|
|
|
|
|
//备(领)料明细
|
|
|
|
|
ProWetMaterialPlanDetail planDetail = proWetMaterialPlanDetailMapper.getWetInfo(workorderId);
|
|
|
|
|
|
|
|
|
|
List<MesPrepareDetailDTO> details = new ArrayList<>();
|
|
|
|
|
MesPrepareDetailDTO detail = new MesPrepareDetailDTO();
|
|
|
|
|
detail.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
detail.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
detail.setRecordId(IdUtils.fastSimpleUUID());
|
|
|
|
|
detail.setPrepareId(whiteOrder.getWorkorderCode() + "L");
|
|
|
|
|
if (planDetail != null) {
|
|
|
|
|
detail.setMaterailName(planDetail.getMaterialName());
|
|
|
|
|
detail.setMaterialCode(planDetail.getMaterialCode());
|
|
|
|
|
detail.setProductDate(planDetail.getProductDate());
|
|
|
|
|
detail.setShiftId(planDetail.getShiftId() + "");
|
|
|
|
|
detail.setProdType("white");
|
|
|
|
|
detail.setFactoryCode(planDetail.getFactoryCode());
|
|
|
|
|
}
|
|
|
|
|
details.add(detail);
|
|
|
|
|
proOrderWorkorderMapper.createPrepareDetails(details);
|
|
|
|
|
|
|
|
|
|
ids.add(workorderId);
|
|
|
|
|
}else{
|
|
|
|
|
//无湿料计划,下发不了
|
|
|
|
|
}
|
|
|
|
|
} else if (whiteOrder != null) {//成品的母工单回传sap
|
|
|
|
|
sapList = new ArrayList<>();
|
|
|
|
|
SapCreateOrder sap = new SapCreateOrder();
|
|
|
|
@ -292,11 +281,34 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
ids.add(workorderId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!CollectionUtils.isEmpty(ids)){
|
|
|
|
|
String[] idsArray = (String[])ids.toArray(new String[ids.size()]);
|
|
|
|
|
List<ProOrderWorkorder> workorders = proOrderWorkorderMapper.getWorkOrderByIds(idsArray);
|
|
|
|
|
for (ProOrderWorkorder workorder : workorders) {
|
|
|
|
|
//关联工艺
|
|
|
|
|
if (StringUtils.isNotBlank(workorder.getRouteCode())) {
|
|
|
|
|
List<ProWorkorderProcessDetail> workDetails = proWorkorderProcessDetailMapper.getWorkOrderDetailsByRouteCode(workorder);
|
|
|
|
|
if (!CollectionUtils.isEmpty(workDetails)) {
|
|
|
|
|
workDetails.forEach(str -> {
|
|
|
|
|
str.setRecordId(IdUtils.fastSimpleUUID());
|
|
|
|
|
str.setWorkorderId(workorder.getWorkorderId());
|
|
|
|
|
str.setStatus("s0");//未执行
|
|
|
|
|
str.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
str.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
str.setFactoryCode(workorder.getFactoryCode());
|
|
|
|
|
});
|
|
|
|
|
proWorkorderProcessDetailMapper.addWorkOrderDetails(workDetails);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//下达工单
|
|
|
|
|
return proOrderWorkorderMapper.downProOrderWorkorderByWorkorderIds(workorderIds);
|
|
|
|
|
return proOrderWorkorderMapper.downProOrderWorkorderByWorkorderIds(idsArray);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //获取最低级材料
|
|
|
|
|