|
|
@ -266,22 +266,32 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
whiteOrder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
whiteOrder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
return proOrderWorkorderMapper.updateWhiteWorkOrder(whiteOrder);
|
|
|
|
return proOrderWorkorderMapper.updateWhiteWorkOrder(whiteOrder);
|
|
|
|
} else if (whiteOrder != null && !"white".equals(whiteOrder.getProdType())) {
|
|
|
|
} else if (whiteOrder != null && !"white".equals(whiteOrder.getProdType())) {
|
|
|
|
List<String> pcodes = new ArrayList<>();//一起下发用
|
|
|
|
List<String> wids = new ArrayList<>();//一起下发用
|
|
|
|
List<String> wcodes = new ArrayList<>();//领料单用
|
|
|
|
List<String> wcodes = new ArrayList<>();//领料单用
|
|
|
|
//成品的母工单//查上一级工单
|
|
|
|
List<String> ordercodes = new ArrayList<>();//关闭订单用
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wids.add(whiteOrder.getWorkorderId());
|
|
|
|
|
|
|
|
wcodes.add(whiteOrder.getWorkorderCode());
|
|
|
|
|
|
|
|
ordercodes.add(whiteOrder.getOrderCode());
|
|
|
|
Boolean isTop = true;
|
|
|
|
Boolean isTop = true;
|
|
|
|
|
|
|
|
//成品的母工单//查上一级工单
|
|
|
|
while(isTop) {
|
|
|
|
while(isTop) {
|
|
|
|
pcodes.add(whiteOrder.getWorkorderId());
|
|
|
|
|
|
|
|
wcodes.add(whiteOrder.getWorkorderCode());
|
|
|
|
|
|
|
|
//查上一级工单
|
|
|
|
//查上一级工单
|
|
|
|
whiteOrder.setWorkorderCode(whiteOrder.getParentOrder());
|
|
|
|
whiteOrder.setWorkorderCode(whiteOrder.getParentOrder());
|
|
|
|
ProOrderWorkorder pWorkOrder = proOrderWorkorderMapper.getPWorkOrder(whiteOrder);
|
|
|
|
ProOrderWorkorder pWorkOrder = proOrderWorkorderMapper.getPWorkOrder(whiteOrder);
|
|
|
|
if(pWorkOrder == null || "0".equals(pWorkOrder.getParentOrder())){
|
|
|
|
if(pWorkOrder != null ){
|
|
|
|
isTop = false;
|
|
|
|
wids.add(pWorkOrder.getWorkorderId());
|
|
|
|
}else{
|
|
|
|
wcodes.add(pWorkOrder.getWorkorderCode());
|
|
|
|
|
|
|
|
ordercodes.add(pWorkOrder.getOrderCode());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if("0".equals(pWorkOrder.getParentOrder())){
|
|
|
|
BeanUtils.copyProperties(pWorkOrder,whiteOrder);
|
|
|
|
BeanUtils.copyProperties(pWorkOrder,whiteOrder);
|
|
|
|
|
|
|
|
isTop = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//顺序母子
|
|
|
|
|
|
|
|
Collections.reverse(wids);
|
|
|
|
|
|
|
|
Collections.reverse(wcodes);
|
|
|
|
sapList = new ArrayList<>();
|
|
|
|
sapList = new ArrayList<>();
|
|
|
|
SapCreateOrder sap = new SapCreateOrder();
|
|
|
|
SapCreateOrder sap = new SapCreateOrder();
|
|
|
|
sap.setWerks(whiteOrder.getFactoryCode());//工厂编码
|
|
|
|
sap.setWerks(whiteOrder.getFactoryCode());//工厂编码
|
|
|
@ -301,36 +311,46 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
sysSapLog.setCreateTime(DateUtils.getNowDate());
|
|
|
|
sysSapLog.setCreateTime(DateUtils.getNowDate());
|
|
|
|
proOrderMapper.addSapLog(sysSapLog);
|
|
|
|
proOrderMapper.addSapLog(sysSapLog);
|
|
|
|
|
|
|
|
|
|
|
|
R<List<String>> r = remoteSapService.SapCreateOrder(sapList);
|
|
|
|
R<List<Map<String, String>>> r = remoteSapService.SapCreateOrder(sapList);
|
|
|
|
logger.info("sap工单回传:" + r.getMsg());
|
|
|
|
logger.info("sap工单回传:" + r.getMsg());
|
|
|
|
if (500 == r.getCode()) {
|
|
|
|
if (500 == r.getCode()) {
|
|
|
|
logger.error("sap工单回传:" + r.getMsg());
|
|
|
|
logger.error("sap工单回传:" + r.getMsg());
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<String> returnCodes = r.getData();
|
|
|
|
List<Map<String, String>> returnMaps = r.getData();
|
|
|
|
|
|
|
|
List<String> returnCodes = new ArrayList<>();
|
|
|
|
|
|
|
|
for(Map<String, String> mapdto:returnMaps){
|
|
|
|
|
|
|
|
returnCodes.add(mapdto.get("LEAD_AUFNR"));
|
|
|
|
|
|
|
|
returnCodes.add(mapdto.get("AUFNR"));
|
|
|
|
|
|
|
|
}
|
|
|
|
Date updateTime = DateUtils.getNowDate();
|
|
|
|
Date updateTime = DateUtils.getNowDate();
|
|
|
|
if (!CollectionUtils.isEmpty(returnCodes)) {
|
|
|
|
if (!CollectionUtils.isEmpty(returnCodes)) {
|
|
|
|
logger.info("sap工单回传sap虚拟工单号:" + StringUtils.join(returnCodes, ","));
|
|
|
|
logger.info("sap工单回传sap虚拟工单号:" + StringUtils.join(returnCodes, ","));
|
|
|
|
|
|
|
|
//按照母子顺序进行更新
|
|
|
|
for (int m=0;m<returnCodes.size();m++) {
|
|
|
|
for (int m=0;m<returnCodes.size();m++) {
|
|
|
|
ProOrderWorkorder oworkSap = new ProOrderWorkorder();
|
|
|
|
ProOrderWorkorder oworkSap = new ProOrderWorkorder();
|
|
|
|
oworkSap.setWorkorderCodeSap(returnCodes.get(m));
|
|
|
|
oworkSap.setWorkorderCodeSap(returnCodes.get(m));
|
|
|
|
oworkSap.setWorkorderId(pcodes.get(returnCodes.size()-(m+1)));//工单编码
|
|
|
|
oworkSap.setWorkorderId(wcodes.get(m));//工单编码
|
|
|
|
oworkSap.setUpdateTime(updateTime);
|
|
|
|
oworkSap.setUpdateTime(updateTime);
|
|
|
|
/**pro_order_workorder**/
|
|
|
|
/**pro_order_workorder**/
|
|
|
|
proOrderWorkorderMapper.updateWorkOrderCodeSap(oworkSap);
|
|
|
|
proOrderWorkorderMapper.updateWorkOrderCodeSap(oworkSap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//测试
|
|
|
|
|
|
|
|
// List<String> returnCodes = new ArrayList<>();
|
|
|
|
|
|
|
|
// returnCodes.add("000100305879");
|
|
|
|
|
|
|
|
// returnCodes.add("000100305878");
|
|
|
|
|
|
|
|
|
|
|
|
//获取领料单
|
|
|
|
//获取领料单
|
|
|
|
Collections.reverse(wcodes);
|
|
|
|
|
|
|
|
this.getMesPrepare(returnCodes,wcodes);
|
|
|
|
this.getMesPrepare(returnCodes,wcodes);
|
|
|
|
|
|
|
|
|
|
|
|
//关闭订单//母订单的订单编码
|
|
|
|
//关闭订单//订单的订单编码
|
|
|
|
R closeR= remoteSapService.sapCloseOrder(whiteOrder.getOrderCode());
|
|
|
|
for(String orderCode:ordercodes){
|
|
|
|
logger.info("下发工单后关闭订单"+whiteOrder.getOrderCode()+":"+closeR.getMsg());
|
|
|
|
R closeR= remoteSapService.sapCloseOrder(orderCode);
|
|
|
|
|
|
|
|
logger.info(workorderId+"下发工单后关闭母订单"+orderCode+":"+closeR.getMsg());
|
|
|
|
|
|
|
|
}
|
|
|
|
//下达工单
|
|
|
|
//下达工单
|
|
|
|
String[] idsArrayAll = (String[])pcodes.toArray(new String[pcodes.size()]);
|
|
|
|
String[] idsArrayAll = (String[])wids.toArray(new String[wids.size()]);
|
|
|
|
return proOrderWorkorderMapper.downWorkorders(idsArrayAll);
|
|
|
|
return proOrderWorkorderMapper.downWorkorders(idsArrayAll);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -349,8 +369,9 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void getMesPrepare(List<String> sapWorkOrders,List<String> workOrders) {
|
|
|
|
public void getMesPrepare(List<String> sapWorkOrders,List<String> workOrders) {
|
|
|
|
for(String sapWorkOrder:sapWorkOrders){
|
|
|
|
Date createDate = DateUtils.getNowDate();
|
|
|
|
logger.info("获取sap领料单:" + sapWorkOrder+"开始");
|
|
|
|
for (int m = 0;m<sapWorkOrders.size();m++) {
|
|
|
|
|
|
|
|
logger.info("获取sap领料单:" + sapWorkOrders.get(m)+"开始");
|
|
|
|
// //添加调用sap日志
|
|
|
|
// //添加调用sap日志
|
|
|
|
// SysSapLog sysSapLog = new SysSapLog();
|
|
|
|
// SysSapLog sysSapLog = new SysSapLog();
|
|
|
|
// sysSapLog.setId(IdUtils.fastSimpleUUID());
|
|
|
|
// sysSapLog.setId(IdUtils.fastSimpleUUID());
|
|
|
@ -360,16 +381,13 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
// sysSapLog.setCreateTime(DateUtils.getNowDate());
|
|
|
|
// sysSapLog.setCreateTime(DateUtils.getNowDate());
|
|
|
|
// proOrderMapper.addSapLog(sysSapLog);
|
|
|
|
// proOrderMapper.addSapLog(sysSapLog);
|
|
|
|
|
|
|
|
|
|
|
|
List<SapMaterialPreparation> sapMaterialPreparationList = remoteSapService.materialPreparation(sapWorkOrder).getData();
|
|
|
|
List<SapMaterialPreparation> sapMaterialPreparationList = remoteSapService.materialPreparation(sapWorkOrders.get(m)).getData();
|
|
|
|
if (CollectionUtils.isEmpty(sapMaterialPreparationList)) {
|
|
|
|
if (CollectionUtils.isEmpty(sapMaterialPreparationList)) {
|
|
|
|
System.out.println("sap无领料单数据");
|
|
|
|
System.out.println("sap无领料单数据");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//取出各领料单
|
|
|
|
//取出各领料单
|
|
|
|
List<String> orderCodes = sapMaterialPreparationList.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toList());
|
|
|
|
String orderCode = sapWorkOrders.get(m);
|
|
|
|
Date createDate = DateUtils.getNowDate();
|
|
|
|
logger.info("sap虚拟工单码:"+orderCode);
|
|
|
|
for (int m = 0;m<orderCodes.size();m++) {
|
|
|
|
|
|
|
|
String orderCode = orderCodes.get(m);
|
|
|
|
|
|
|
|
logger.info("领料单内容:"+orderCode);
|
|
|
|
|
|
|
|
/**mes_prepare**/
|
|
|
|
/**mes_prepare**/
|
|
|
|
String mesPrepareId = IdUtils.fastSimpleUUID();
|
|
|
|
String mesPrepareId = IdUtils.fastSimpleUUID();
|
|
|
|
MesPrepareDTO mesPrepare0 = new MesPrepareDTO();
|
|
|
|
MesPrepareDTO mesPrepare0 = new MesPrepareDTO();
|
|
|
@ -401,6 +419,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
detail.setBuyFlag(sap.getDBSKZ());//直接采购标识
|
|
|
|
detail.setBuyFlag(sap.getDBSKZ());//直接采购标识
|
|
|
|
detail.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
detail.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
detail.setCreateTime(createDate);
|
|
|
|
detail.setCreateTime(createDate);
|
|
|
|
|
|
|
|
detail.setParentWorkOrder(workOrders.get(0));
|
|
|
|
details.add(detail);
|
|
|
|
details.add(detail);
|
|
|
|
logger.info("领料单内容detail:"+sap.getRSPOS()+","+sap.getMATNR()+","+
|
|
|
|
logger.info("领料单内容detail:"+sap.getRSPOS()+","+sap.getMATNR()+","+
|
|
|
|
sap.getMAKTX()+","+sap.getWERKS()+","+ sap.getLGORT()+","+
|
|
|
|
sap.getMAKTX()+","+sap.getWERKS()+","+ sap.getLGORT()+","+
|
|
|
@ -409,8 +428,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
proOrderWorkorderMapper.insertMesPrepareDetails(details);
|
|
|
|
proOrderWorkorderMapper.insertMesPrepareDetails(details);
|
|
|
|
logger.info("获取sap领料单:" + sapWorkOrder+"结束");
|
|
|
|
logger.info("获取sap领料单:" + sapWorkOrders.get(m)+"结束");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -773,18 +791,11 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
if (splitOrderDTO.getRouteCode() != null) {
|
|
|
|
if (splitOrderDTO.getRouteCode() != null) {
|
|
|
|
proOrderWorkorder.setRouteCode(splitOrderDTO.getRouteCode());
|
|
|
|
proOrderWorkorder.setRouteCode(splitOrderDTO.getRouteCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// // 白坯工单返修-车数
|
|
|
|
|
|
|
|
// if (proOrderWorkorder.getProdType().equals("white")) {
|
|
|
|
|
|
|
|
// if (splitOrderDTO.getCarNum() != null) {
|
|
|
|
|
|
|
|
// proOrderWorkorder.setCarNum(splitOrderDTO.getCarNum());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proOrderWorkorderMapper.updateProOrderWorkorder(proOrderWorkorder);
|
|
|
|
proOrderWorkorderMapper.updateProOrderWorkorder(proOrderWorkorder);
|
|
|
|
// 删除工单下对应批次信息
|
|
|
|
// 删除工单下对应批次信息
|
|
|
|
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderId(proOrderWorkorder.getWorkorderId());
|
|
|
|
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderId(proOrderWorkorder.getWorkorderId());
|
|
|
|
|
|
|
|
|
|
|
|
// System.out.println("这里是workorderCode------------》"+proOrderWorkorder.getWorkorderCode());
|
|
|
|
|
|
|
|
// 生成对应批次表
|
|
|
|
// 生成对应批次表
|
|
|
|
workBatch.setWorkorderId(proOrderWorkorder.getWorkorderId());
|
|
|
|
workBatch.setWorkorderId(proOrderWorkorder.getWorkorderId());
|
|
|
|
|
|
|
|
|
|
|
@ -840,13 +851,6 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
if (!(proOrderWorkorder.getStatus().equals("w0") || proOrderWorkorder.getStatus().equals("w1"))) {
|
|
|
|
if (!(proOrderWorkorder.getStatus().equals("w0") || proOrderWorkorder.getStatus().equals("w1"))) {
|
|
|
|
return error("工单已生产,不可变更!");
|
|
|
|
return error("工单已生产,不可变更!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// // 白坯工单所在湿料计划下发不允许变更
|
|
|
|
|
|
|
|
// if (proOrderWorkorder.getProdType().equals("white")) {
|
|
|
|
|
|
|
|
// ProWetMaterialPlan plan = proWetMaterialPlanMapper.selectProWetMaterialPlanByWorkId(proOrderWorkorder.getWorkorderId());
|
|
|
|
|
|
|
|
// if (plan != null) {
|
|
|
|
|
|
|
|
// return error("工单所在湿料计划已下发,不允许变更!");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
return success();
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1081,5 +1085,12 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return success("变更成功");
|
|
|
|
return success("变更成功");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void main(String args[]){
|
|
|
|
|
|
|
|
List<String> wcodes =new ArrayList<>();
|
|
|
|
|
|
|
|
wcodes.add("aaa");
|
|
|
|
|
|
|
|
wcodes.add("bbb");
|
|
|
|
|
|
|
|
wcodes.add("ccc");
|
|
|
|
|
|
|
|
Collections.reverse(wcodes);
|
|
|
|
|
|
|
|
System.out.println(StringUtils.join(wcodes, ","));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|