添加存入数据库的条件

master
zhouhy 1 year ago
parent ed808b559d
commit dd3f65b798

@ -111,11 +111,11 @@ public class SAPPortServiceImpl implements ISAPPortService {
//转物料实体类 保存数据
baseOrderInfoVos = storageService.insertSAPBaseOrderInfo(resultVo);
//保存接口日志
PortLogUtils.savePortLog(werks.getItem().get(0).get("WERKS"), "获取SAP物料主数据" + intervalDate, "getSAPBaseOrderInfo", requestParam, result, null);
PortLogUtils.savePortLog(werks.getItem().get(0).get("WERKS"), "获取生产工单" + intervalDate, "getSAPBaseOrderInfo", requestParam, result, null);
} catch (Exception e){
//保存接口日志
System.out.println(e.getMessage());
PortLogUtils.savePortLog(werks.getItem().get(0).get("WERKS"), "获取SAP物料主数据" + intervalDate, "getSAPBaseOrderInfo", requestParam, result, e.toString());
PortLogUtils.savePortLog(werks.getItem().get(0).get("WERKS"), "获取生产工单" + intervalDate, "getSAPBaseOrderInfo", requestParam, result, e.toString());
}
@ -162,11 +162,11 @@ public class SAPPortServiceImpl implements ISAPPortService {
//转物料实体类 保存数据
baseDeviceLedgersVos = storageService.insertSAPDeviceLedger(resultVo);
//保存接口日志
PortLogUtils.savePortLog(werks.getItem().get(0).get("IWERK"), "获取SAP物料主数据" + intervalDate, "getSAPBaseDeviceLedger", requestParam, result, null);
PortLogUtils.savePortLog(werks.getItem().get(0).get("IWERK"), "获取设备台账数据" + intervalDate, "getSAPBaseDeviceLedger", requestParam, result, null);
} catch (Exception e) {
//保存接口日志
System.out.println(e.getMessage());
PortLogUtils.savePortLog(werks.getItem().get(0).get("IWERK"), "获取SAP物料主数据" + intervalDate, "getSAPBaseDeviceLedger", requestParam, result, e.toString());
PortLogUtils.savePortLog(werks.getItem().get(0).get("IWERK"), "获取设备台账数据" + intervalDate, "getSAPBaseDeviceLedger", requestParam, result, e.toString());
}
return baseDeviceLedgersVos;
}
@ -206,11 +206,11 @@ public class SAPPortServiceImpl implements ISAPPortService {
//转物料实体类 保存数据
orderBomInfosVos = storageService.insertSAPOrderBomInfo(resultVo);
//保存接口日志
PortLogUtils.savePortLog(werks.getItem().get(0).get("IWERK"), "获取SAP物料主数据" + intervalDate, "getSapBaseBomInfo", requestParam, result, null);
PortLogUtils.savePortLog(werks.getItem().get(0).get("IWERK"), "获取产品bom数据" + intervalDate, "getSapBaseBomInfo", requestParam, result, null);
} catch (Exception e) {
//保存接口日志
System.out.println(e.getMessage());
PortLogUtils.savePortLog(werks.getItem().get(0).get("IWERK"), "获取SAP物料主数据" + intervalDate, "getSapBaseBomInfo", requestParam, result, e.toString());
PortLogUtils.savePortLog(werks.getItem().get(0).get("IWERK"), "获取产品bom数据" + intervalDate, "getSapBaseBomInfo", requestParam, result, e.toString());
}
return orderBomInfosVos;
}

@ -55,6 +55,10 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
ArrayList<BaseMaterialInfo> baseMaterialInfoArrayList = new ArrayList<>();
List<HashMap<String, String>> itemList = resultVo.getO_TAB().get("item");
for (HashMap<String, String> map : itemList) {
BaseMaterialInfo baseMaterialInfo = new BaseMaterialInfo();
baseMaterialInfo.setMaterialCode(map.get("MATNR"));
List<BaseMaterialInfo> baseMaterialInfoList = baseMaterialInfoService.selectBaseMaterialInfoList(baseMaterialInfo);
if (!baseMaterialInfoList.isEmpty()){
BaseMaterialInfo materialInfo = new BaseMaterialInfo();
materialInfo.setMaterialCode(map.get("MATNR"));
materialInfo.setMaterialName(map.get("MAKTX"));
@ -64,6 +68,7 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
baseMaterialInfoService.insertBaseMaterialInfo(materialInfo);
baseMaterialInfoArrayList.add(materialInfo);
}
}
return baseMaterialInfoArrayList;
}
@ -76,7 +81,7 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
ArrayList<BaseOrderInfo> baseOrderInfoList = new ArrayList<>();
List<HashMap<String, String>> itemList = resultVo.getO_TAB().get("item");
for (HashMap<String, String> map : itemList) {
int item = 0;
String aufnr = map.get("AUFNR");
BaseOrderInfo boInfo = new BaseOrderInfo();
boInfo.setOrderCode(aufnr);
@ -116,23 +121,12 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
public ArrayList<BaseDeviceLedger> insertSAPDeviceLedger(SAPResultVo resultVo) throws ParseException {
ArrayList<BaseDeviceLedger> baseDeviceLedgerArrayList = new ArrayList<>();
List<HashMap<String, String>> itemList = resultVo.getO_TAB().get("item");
BaseDeviceLedger device = new BaseDeviceLedger();
for (HashMap<String, String> map : itemList) {
int item = 0;
BaseDeviceLedger device = new BaseDeviceLedger();
device.setDeviceCode(map.get("EQUNR"));
List<BaseDeviceLedger> baseDeviceLedgers = baseDeviceLedgerService.selectBaseDeviceLedgerList(device);
//查出值进行比对 如果数据库中已有该字段则忽略本次数据
for (int i=0;i<baseDeviceLedgers.size();i++){
if (baseDeviceLedgers.get(i).getCostCenter().equals(map.get("KOSTL"))&&
baseDeviceLedgers.get(i).getDeviceCode().equals(map.get("EQUNR"))
&&baseDeviceLedgers.get(i).getFactoryCode().equals(map.get("IWERK"))
&&baseDeviceLedgers.get(i).getCostCenter()!=null
&&baseDeviceLedgers.get(i).getFactoryCode()!=null
&&baseDeviceLedgers.get(i).getDeviceCode()!=null){
//忽略标识
item = 1;
}
}
if (item==0){
if (!baseDeviceLedgers.isEmpty()){
BaseDeviceLedger deviceLedger = new BaseDeviceLedger();
deviceLedger.setCostCenter(map.get("KOSTL"));//
deviceLedger.setFactoryCode(map.get("IWERK"));
@ -157,20 +151,26 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
List<HashMap<String, String>> itemList = resultVo.getO_TAB().get("item");
for (HashMap<String, String> map : itemList) {
OrderBomInfo orderBomInfo = new OrderBomInfo();
orderBomInfo.setFactoryCode(map.get("WERKS"));
orderBomInfo.setParentId(map.get("MATNR"));
orderBomInfo.setMaterialCode(map.get("IDNRK"));
if (!map.get("MENGE").isEmpty()){
orderBomInfo.setStandardAmount(Long.parseLong(map.get("MENGE")));
}
orderBomInfo.setCreatedTime(DateUtils.getNowDate());
OrderBomInfo orderBomInfo1 = new OrderBomInfo();
orderBomInfo1.setBomCode(map.get("IDNRK"));
List<OrderBomInfo> orderBomInfos = orderBomInfoService.selectOrderBomInfoList(orderBomInfo1);
if (!orderBomInfos.isEmpty()) {
OrderBomInfo orderBomInfo = new OrderBomInfo();
orderBomInfo.setFactoryCode(map.get("WERKS"));
orderBomInfo.setParentId(map.get("MATNR"));
orderBomInfo.setMaterialCode(map.get("IDNRK"));
if (!map.get("MENGE").isEmpty()) {
orderBomInfo.setStandardAmount(Long.parseLong(map.get("MENGE")));
}
orderBomInfo.setVbeln(map.get("VBELN"));
orderBomInfo.setVbpos(map.get("VBPOS"));
orderBomInfo.setCreatedTime(DateUtils.getNowDate());
// baseBomInfo.setCreatedBy(SecurityUtils.getLoginUser().getUsername());
orderBomInfoService.insertOrderBomInfo(orderBomInfo);
orderBomInfoList.add(orderBomInfo);
orderBomInfoService.insertOrderBomInfo(orderBomInfo);
orderBomInfoList.add(orderBomInfo);
}
}
return orderBomInfoList;
}

Loading…
Cancel
Save