|
|
|
@ -266,22 +266,32 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
whiteOrder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
return proOrderWorkorderMapper.updateWhiteWorkOrder(whiteOrder);
|
|
|
|
|
} 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> ordercodes = new ArrayList<>();//关闭订单用
|
|
|
|
|
|
|
|
|
|
wids.add(whiteOrder.getWorkorderId());
|
|
|
|
|
wcodes.add(whiteOrder.getWorkorderCode());
|
|
|
|
|
ordercodes.add(whiteOrder.getOrderCode());
|
|
|
|
|
Boolean isTop = true;
|
|
|
|
|
//成品的母工单//查上一级工单
|
|
|
|
|
while(isTop) {
|
|
|
|
|
pcodes.add(whiteOrder.getWorkorderId());
|
|
|
|
|
wcodes.add(whiteOrder.getWorkorderCode());
|
|
|
|
|
//查上一级工单
|
|
|
|
|
whiteOrder.setWorkorderCode(whiteOrder.getParentOrder());
|
|
|
|
|
ProOrderWorkorder pWorkOrder = proOrderWorkorderMapper.getPWorkOrder(whiteOrder);
|
|
|
|
|
if(pWorkOrder == null || "0".equals(pWorkOrder.getParentOrder())){
|
|
|
|
|
isTop = false;
|
|
|
|
|
}else{
|
|
|
|
|
if(pWorkOrder != null ){
|
|
|
|
|
wids.add(pWorkOrder.getWorkorderId());
|
|
|
|
|
wcodes.add(pWorkOrder.getWorkorderCode());
|
|
|
|
|
ordercodes.add(pWorkOrder.getOrderCode());
|
|
|
|
|
}
|
|
|
|
|
if("0".equals(pWorkOrder.getParentOrder())){
|
|
|
|
|
BeanUtils.copyProperties(pWorkOrder,whiteOrder);
|
|
|
|
|
isTop = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//顺序母子
|
|
|
|
|
Collections.reverse(wids);
|
|
|
|
|
Collections.reverse(wcodes);
|
|
|
|
|
sapList = new ArrayList<>();
|
|
|
|
|
SapCreateOrder sap = new SapCreateOrder();
|
|
|
|
|
sap.setWerks(whiteOrder.getFactoryCode());//工厂编码
|
|
|
|
@ -301,36 +311,46 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
sysSapLog.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
proOrderMapper.addSapLog(sysSapLog);
|
|
|
|
|
|
|
|
|
|
R<List<String>> r = remoteSapService.SapCreateOrder(sapList);
|
|
|
|
|
R<List<Map<String, String>>> r = remoteSapService.SapCreateOrder(sapList);
|
|
|
|
|
logger.info("sap工单回传:" + r.getMsg());
|
|
|
|
|
if (500 == r.getCode()) {
|
|
|
|
|
logger.error("sap工单回传:" + r.getMsg());
|
|
|
|
|
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();
|
|
|
|
|
if (!CollectionUtils.isEmpty(returnCodes)) {
|
|
|
|
|
logger.info("sap工单回传sap虚拟工单号:" + StringUtils.join(returnCodes, ","));
|
|
|
|
|
//按照母子顺序进行更新
|
|
|
|
|
for (int m=0;m<returnCodes.size();m++) {
|
|
|
|
|
ProOrderWorkorder oworkSap = new ProOrderWorkorder();
|
|
|
|
|
oworkSap.setWorkorderCodeSap(returnCodes.get(m));
|
|
|
|
|
oworkSap.setWorkorderId(pcodes.get(returnCodes.size()-(m+1)));//工单编码
|
|
|
|
|
oworkSap.setWorkorderId(wcodes.get(m));//工单编码
|
|
|
|
|
oworkSap.setUpdateTime(updateTime);
|
|
|
|
|
/**pro_order_workorder**/
|
|
|
|
|
proOrderWorkorderMapper.updateWorkOrderCodeSap(oworkSap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//测试
|
|
|
|
|
// List<String> returnCodes = new ArrayList<>();
|
|
|
|
|
// returnCodes.add("000100305879");
|
|
|
|
|
// returnCodes.add("000100305878");
|
|
|
|
|
|
|
|
|
|
//获取领料单
|
|
|
|
|
Collections.reverse(wcodes);
|
|
|
|
|
this.getMesPrepare(returnCodes,wcodes);
|
|
|
|
|
|
|
|
|
|
//关闭订单//母订单的订单编码
|
|
|
|
|
R closeR= remoteSapService.sapCloseOrder(whiteOrder.getOrderCode());
|
|
|
|
|
logger.info("下发工单后关闭订单"+whiteOrder.getOrderCode()+":"+closeR.getMsg());
|
|
|
|
|
|
|
|
|
|
//关闭订单//订单的订单编码
|
|
|
|
|
for(String orderCode:ordercodes){
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -349,8 +369,9 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void getMesPrepare(List<String> sapWorkOrders,List<String> workOrders) {
|
|
|
|
|
for(String sapWorkOrder:sapWorkOrders){
|
|
|
|
|
logger.info("获取sap领料单:" + sapWorkOrder+"开始");
|
|
|
|
|
Date createDate = DateUtils.getNowDate();
|
|
|
|
|
for (int m = 0;m<sapWorkOrders.size();m++) {
|
|
|
|
|
logger.info("获取sap领料单:" + sapWorkOrders.get(m)+"开始");
|
|
|
|
|
// //添加调用sap日志
|
|
|
|
|
// SysSapLog sysSapLog = new SysSapLog();
|
|
|
|
|
// sysSapLog.setId(IdUtils.fastSimpleUUID());
|
|
|
|
@ -360,57 +381,54 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
// sysSapLog.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
// proOrderMapper.addSapLog(sysSapLog);
|
|
|
|
|
|
|
|
|
|
List<SapMaterialPreparation> sapMaterialPreparationList = remoteSapService.materialPreparation(sapWorkOrder).getData();
|
|
|
|
|
List<SapMaterialPreparation> sapMaterialPreparationList = remoteSapService.materialPreparation(sapWorkOrders.get(m)).getData();
|
|
|
|
|
if (CollectionUtils.isEmpty(sapMaterialPreparationList)) {
|
|
|
|
|
System.out.println("sap无领料单数据");
|
|
|
|
|
}
|
|
|
|
|
//取出各领料单
|
|
|
|
|
List<String> orderCodes = sapMaterialPreparationList.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toList());
|
|
|
|
|
Date createDate = DateUtils.getNowDate();
|
|
|
|
|
for (int m = 0;m<orderCodes.size();m++) {
|
|
|
|
|
String orderCode = orderCodes.get(m);
|
|
|
|
|
logger.info("领料单内容:"+orderCode);
|
|
|
|
|
/**mes_prepare**/
|
|
|
|
|
String mesPrepareId = IdUtils.fastSimpleUUID();
|
|
|
|
|
MesPrepareDTO mesPrepare0 = new MesPrepareDTO();
|
|
|
|
|
mesPrepare0.setPrepareId(mesPrepareId);
|
|
|
|
|
mesPrepare0.setWorkorderCode(workOrders.get(m));
|
|
|
|
|
mesPrepare0.setWorkorderName(orderCode);//工单(子)
|
|
|
|
|
mesPrepare0.setCreateTime(createDate);
|
|
|
|
|
mesPrepare0.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
mesPrepare0.setStatus("L0");//默认待确认
|
|
|
|
|
proOrderWorkorderMapper.insertMesPrepare(mesPrepare0);
|
|
|
|
|
/**mes_prepare_detail**/
|
|
|
|
|
List<MesPrepareDetailDTO> details = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
MesPrepareDetailDTO detail = null;
|
|
|
|
|
for (SapMaterialPreparation sap : sapMaterialPreparationList) {
|
|
|
|
|
detail = new MesPrepareDetailDTO();
|
|
|
|
|
detail.setPrepareId(mesPrepareId);
|
|
|
|
|
detail.setRecordId(IdUtils.fastSimpleUUID());
|
|
|
|
|
detail.setAttr1(sap.getRSPOS());//预留/相关需求的项目编号
|
|
|
|
|
detail.setMaterialCode(sap.getMATNR());//物料号
|
|
|
|
|
detail.setMaterailName(sap.getMAKTX());//物料描述(短文本)
|
|
|
|
|
detail.setFactoryCode(sap.getWERKS());//工厂
|
|
|
|
|
detail.setLocator(sap.getLGORT());//库存地点
|
|
|
|
|
detail.setNeedDate(sap.getBDTER());//组件的需求日期
|
|
|
|
|
detail.setQuantity(sap.getBDMNG());////需求量
|
|
|
|
|
detail.setFundQuanlity(sap.getZQLSL());//欠料数量
|
|
|
|
|
detail.setUnit(sap.getMEINS());//基本计量单位
|
|
|
|
|
detail.setRecoil(sap.getRGEKZ());//反冲标识
|
|
|
|
|
detail.setBuyFlag(sap.getDBSKZ());//直接采购标识
|
|
|
|
|
detail.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
detail.setCreateTime(createDate);
|
|
|
|
|
details.add(detail);
|
|
|
|
|
logger.info("领料单内容detail:"+sap.getRSPOS()+","+sap.getMATNR()+","+
|
|
|
|
|
sap.getMAKTX()+","+sap.getWERKS()+","+ sap.getLGORT()+","+
|
|
|
|
|
sap.getBDTER()+","+sap.getBDMNG()+","+sap.getZQLSL()+","+
|
|
|
|
|
sap.getMEINS()+","+sap.getRGEKZ()+","+sap.getDBSKZ()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
proOrderWorkorderMapper.insertMesPrepareDetails(details);
|
|
|
|
|
logger.info("获取sap领料单:" + sapWorkOrder+"结束");
|
|
|
|
|
String orderCode = sapWorkOrders.get(m);
|
|
|
|
|
logger.info("sap虚拟工单码:"+orderCode);
|
|
|
|
|
/**mes_prepare**/
|
|
|
|
|
String mesPrepareId = IdUtils.fastSimpleUUID();
|
|
|
|
|
MesPrepareDTO mesPrepare0 = new MesPrepareDTO();
|
|
|
|
|
mesPrepare0.setPrepareId(mesPrepareId);
|
|
|
|
|
mesPrepare0.setWorkorderCode(workOrders.get(m));
|
|
|
|
|
mesPrepare0.setWorkorderName(orderCode);//工单(子)
|
|
|
|
|
mesPrepare0.setCreateTime(createDate);
|
|
|
|
|
mesPrepare0.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
mesPrepare0.setStatus("L0");//默认待确认
|
|
|
|
|
proOrderWorkorderMapper.insertMesPrepare(mesPrepare0);
|
|
|
|
|
/**mes_prepare_detail**/
|
|
|
|
|
List<MesPrepareDetailDTO> details = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
MesPrepareDetailDTO detail = null;
|
|
|
|
|
for (SapMaterialPreparation sap : sapMaterialPreparationList) {
|
|
|
|
|
detail = new MesPrepareDetailDTO();
|
|
|
|
|
detail.setPrepareId(mesPrepareId);
|
|
|
|
|
detail.setRecordId(IdUtils.fastSimpleUUID());
|
|
|
|
|
detail.setAttr1(sap.getRSPOS());//预留/相关需求的项目编号
|
|
|
|
|
detail.setMaterialCode(sap.getMATNR());//物料号
|
|
|
|
|
detail.setMaterailName(sap.getMAKTX());//物料描述(短文本)
|
|
|
|
|
detail.setFactoryCode(sap.getWERKS());//工厂
|
|
|
|
|
detail.setLocator(sap.getLGORT());//库存地点
|
|
|
|
|
detail.setNeedDate(sap.getBDTER());//组件的需求日期
|
|
|
|
|
detail.setQuantity(sap.getBDMNG());////需求量
|
|
|
|
|
detail.setFundQuanlity(sap.getZQLSL());//欠料数量
|
|
|
|
|
detail.setUnit(sap.getMEINS());//基本计量单位
|
|
|
|
|
detail.setRecoil(sap.getRGEKZ());//反冲标识
|
|
|
|
|
detail.setBuyFlag(sap.getDBSKZ());//直接采购标识
|
|
|
|
|
detail.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
detail.setCreateTime(createDate);
|
|
|
|
|
detail.setParentWorkOrder(workOrders.get(0));
|
|
|
|
|
details.add(detail);
|
|
|
|
|
logger.info("领料单内容detail:"+sap.getRSPOS()+","+sap.getMATNR()+","+
|
|
|
|
|
sap.getMAKTX()+","+sap.getWERKS()+","+ sap.getLGORT()+","+
|
|
|
|
|
sap.getBDTER()+","+sap.getBDMNG()+","+sap.getZQLSL()+","+
|
|
|
|
|
sap.getMEINS()+","+sap.getRGEKZ()+","+sap.getDBSKZ()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
proOrderWorkorderMapper.insertMesPrepareDetails(details);
|
|
|
|
|
logger.info("获取sap领料单:" + sapWorkOrders.get(m)+"结束");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -773,18 +791,11 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
if (splitOrderDTO.getRouteCode() != null) {
|
|
|
|
|
proOrderWorkorder.setRouteCode(splitOrderDTO.getRouteCode());
|
|
|
|
|
}
|
|
|
|
|
// // 白坯工单返修-车数
|
|
|
|
|
// if (proOrderWorkorder.getProdType().equals("white")) {
|
|
|
|
|
// if (splitOrderDTO.getCarNum() != null) {
|
|
|
|
|
// proOrderWorkorder.setCarNum(splitOrderDTO.getCarNum());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
proOrderWorkorderMapper.updateProOrderWorkorder(proOrderWorkorder);
|
|
|
|
|
// 删除工单下对应批次信息
|
|
|
|
|
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderId(proOrderWorkorder.getWorkorderId());
|
|
|
|
|
|
|
|
|
|
// System.out.println("这里是workorderCode------------》"+proOrderWorkorder.getWorkorderCode());
|
|
|
|
|
// 生成对应批次表
|
|
|
|
|
workBatch.setWorkorderId(proOrderWorkorder.getWorkorderId());
|
|
|
|
|
|
|
|
|
@ -840,13 +851,6 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
if (!(proOrderWorkorder.getStatus().equals("w0") || proOrderWorkorder.getStatus().equals("w1"))) {
|
|
|
|
|
return error("工单已生产,不可变更!");
|
|
|
|
|
}
|
|
|
|
|
// // 白坯工单所在湿料计划下发不允许变更
|
|
|
|
|
// if (proOrderWorkorder.getProdType().equals("white")) {
|
|
|
|
|
// ProWetMaterialPlan plan = proWetMaterialPlanMapper.selectProWetMaterialPlanByWorkId(proOrderWorkorder.getWorkorderId());
|
|
|
|
|
// if (plan != null) {
|
|
|
|
|
// return error("工单所在湿料计划已下发,不允许变更!");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
return success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1081,5 +1085,12 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
}
|
|
|
|
|
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, ","));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|