【物料主数据】同步HANA物料价格字段

This commit is contained in:
10001392 2024-12-24 16:37:41 +08:00
parent 5ffbb9c45d
commit 717c10f5bd
5 changed files with 57 additions and 2 deletions

View File

@ -95,11 +95,12 @@ public class SaticScheduleTask {
} }
/** /**
* 每天凌晨12点从SAP获取物料的最近出库时间最近采购价格最近采购日期 * 每天凌晨12点从SAP获取物料的最近出库时间最近采购价格最近采购日期物料价格
* 只针对物料状态material_state为1:激活 2:禁止采购 3:售后专用 * 只针对物料状态material_state为1:激活 2:禁止采购 3:售后专用
* 流程状态15已审核 100: 历史正式物料(已审核) * 流程状态15已审核 100: 历史正式物料(已审核)
*/ */
@Scheduled(cron = "0 0 3 * * ?") @Scheduled(cron = "0 0 3 * * ?")
// @Scheduled(cron = "0 0/2 * * * ? ") // 测试使用每2分钟
public void materialPurchaseInfo() throws Exception { public void materialPurchaseInfo() throws Exception {
materialMainService.materialPurchaseInfo(); materialMainService.materialPurchaseInfo();
} }

View File

@ -376,6 +376,13 @@ public class MaterialMainEntity implements Serializable {
@ApiModelProperty("通用程度") @ApiModelProperty("通用程度")
private String generalLevel; private String generalLevel;
/**
* 物料价格
*/
@TableField(value = "material_price")
@ApiModelProperty(value = "物料价格")
private BigDecimal materialPrice;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -65,4 +65,6 @@ public class SopMaterialInfo {
private String PLIFZ; private String PLIFZ;
// 采购属性信息 end // 采购属性信息 end
@ApiModelProperty("物料价格")
private String materialPrice;
} }

View File

@ -1948,6 +1948,22 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
return sopMaterialInfos; return sopMaterialInfos;
} }
public List<SopMaterialInfo> getSapPriceInfo(List<String> materialNos) throws Exception {
String materialNoSnippet = CollUtil.join(materialNos, "','");
materialNoSnippet = "'".concat(materialNoSnippet).concat("'");
// select IDNRK,RECORDMODE,TXTLG,MENGE,MEINS,OBDAYS,EKGRP,BESKZ,SOBSL,MATL_GROUP,PICTURE,DATA_UPDATE, STORE, MAKER,PROPOSER,MOVE_TIME,DEPT,LVORM,VPRSV,PEINH,VERPR,STPRS,WAERS from SAPABAP1."/BIC/AZQT_M00122"
String sql = "select IDNRK,(case when peinh = 0 then 0 when peinh <> 0 and vprsv = 'V' then verpr / peinh else stprs / peinh end) materialPrice from SAPABAP1.\"/BIC/AZQT_M00122\"";
sql = sql.concat(" where idnrk in ( ");
sql = sql.concat(materialNoSnippet).concat(" ) ");
log.info("获取HANA物料价格");
PreparedStatement preparedStatement = sopConnection.prepareStatement(sql);
ResultSet resultSet = preparedStatement.executeQuery();
List<SopMaterialInfo> sopMaterialInfos = resultSetToBean(resultSet, SopMaterialInfo.class);
return sopMaterialInfos;
}
/** /**
* 获取HANA物料采购属性信息 * 获取HANA物料采购属性信息
* @param materialNos * @param materialNos
@ -2224,8 +2240,13 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
} }
public void materialPurchaseInfo() throws Exception { public void materialPurchaseInfo() throws Exception {
log.info("获取物料的最近出库时间、最近采购价格、最近采购日期、物料价格开始");
MaterialMainQuery query = new MaterialMainQuery(); MaterialMainQuery query = new MaterialMainQuery();
query.setPage(1L).setPageSize(1000L); query.setPage(1L).setPageSize(1000L);
// 测试数据
// query.setMaterialNos(Arrays.asList("1100014371", "1100014372", "1100016795", "1100016796", "1100018193", "1100022522", "1100032454", "1100033452", "1100033453", "1100004194",
// "1100006841", "1100007730", "1100007731", "1100007745", "1100009562", "1100009564", "1100011033", "1100012697", "1100012991", "1100013133", "1100017018", "1100018720",
// "1100022362", "1100022363", "1100022364", "1100022365", "1100022366", "1100022367", "1100023084", "1100023836", "1100034280", "1100039507", "110004315"));
query.setMaterialClass(0); query.setMaterialClass(0);
int pageCount = this.downExcelGetListPages(query) + 1; int pageCount = this.downExcelGetListPages(query) + 1;
@ -2250,7 +2271,7 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
this.updateMaterialPurchaseInfo(filterList); this.updateMaterialPurchaseInfo(filterList);
} }
log.info("获取物料的最近出库时间、最近采购价格、最近采购日期结束"); log.info("获取物料的最近出库时间、最近采购价格、最近采购日期、物料价格结束");
} }
private void updateMaterialPurchaseInfo(List<MaterialMainEntity> filterList) { private void updateMaterialPurchaseInfo(List<MaterialMainEntity> filterList) {

View File

@ -57,8 +57,16 @@ public class SapInfoService {
System.out.println("获取sap最近库存时间数据错误"); System.out.println("获取sap最近库存时间数据错误");
} }
}, futureTaskPool); }, futureTaskPool);
CompletableFuture<Void> task6 = CompletableFuture.runAsync(() -> {
try {
initSapPriceInfo(result);
} catch (Exception e) {
System.out.println("获取sap物料价格数据错误".concat(e.getMessage()));
}
}, futureTaskPool);
task4.join(); task4.join();
task5.join(); task5.join();
task6.join();
} }
public void initSapInfo(List<Map<String, Object>> result) { public void initSapInfo(List<Map<String, Object>> result) {
@ -153,6 +161,22 @@ public class SapInfoService {
} }
} }
private void initSapPriceInfo(List<Map<String, Object>> data) throws Exception {
List<String> materialNos = data.stream().map(u -> u.get("materialNo").toString()).collect(Collectors.toList());
List<SopMaterialInfo> sapMaterialList = materialMainService.getSapPriceInfo(handlerToSapMaterialNo(materialNos));
if (sapMaterialList != null && sapMaterialList.size() > 0) {
Map<String, SopMaterialInfo> sapMaterialMp = sapMaterialList.stream().collect(Collectors.toMap(SopMaterialInfo::getIDNRK, user -> user, (oldValue, newValue) -> newValue));
data.forEach(m -> {
if (sapMaterialMp.containsKey(handlerMaterialNoToSapMaterialNo(m.get("materialNo").toString()))) {
SopMaterialInfo sapMaterialInfo = sapMaterialMp.get(handlerMaterialNoToSapMaterialNo(m.get("materialNo").toString()));
if (sapMaterialInfo != null) {
m.put("materialPrice", sapMaterialInfo.getMaterialPrice());
}
}
});
}
}
public void materialPurchasePropInfoTask(List<Map<String, Object>> result) { public void materialPurchasePropInfoTask(List<Map<String, Object>> result) {
CompletableFuture<Void> task = CompletableFuture.runAsync(() -> { CompletableFuture<Void> task = CompletableFuture.runAsync(() -> {
try { try {