【物料主数据】同步HANA物料价格字段
This commit is contained in:
parent
5ffbb9c45d
commit
717c10f5bd
|
|
@ -95,11 +95,12 @@ public class SaticScheduleTask {
|
|||
}
|
||||
|
||||
/**
|
||||
* 每天凌晨12点从SAP获取物料的最近出库时间、最近采购价格、最近采购日期
|
||||
* 每天凌晨12点从SAP获取物料的最近出库时间、最近采购价格、最近采购日期、物料价格
|
||||
* 只针对物料状态material_state为1:激活 2:禁止采购 3:售后专用
|
||||
* 流程状态:15:已审核 100: 历史正式物料(已审核)
|
||||
*/
|
||||
@Scheduled(cron = "0 0 3 * * ?")
|
||||
// @Scheduled(cron = "0 0/2 * * * ? ") // 测试使用,每2分钟
|
||||
public void materialPurchaseInfo() throws Exception {
|
||||
materialMainService.materialPurchaseInfo();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -376,6 +376,13 @@ public class MaterialMainEntity implements Serializable {
|
|||
@ApiModelProperty("通用程度")
|
||||
private String generalLevel;
|
||||
|
||||
/**
|
||||
* 物料价格
|
||||
*/
|
||||
@TableField(value = "material_price")
|
||||
@ApiModelProperty(value = "物料价格")
|
||||
private BigDecimal materialPrice;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,4 +65,6 @@ public class SopMaterialInfo {
|
|||
private String PLIFZ;
|
||||
// 采购属性信息 end
|
||||
|
||||
@ApiModelProperty("物料价格")
|
||||
private String materialPrice;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1948,6 +1948,22 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
|
|||
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物料采购属性信息
|
||||
* @param materialNos
|
||||
|
|
@ -2224,8 +2240,13 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
|
|||
}
|
||||
|
||||
public void materialPurchaseInfo() throws Exception {
|
||||
log.info("获取物料的最近出库时间、最近采购价格、最近采购日期、物料价格开始");
|
||||
MaterialMainQuery query = new MaterialMainQuery();
|
||||
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);
|
||||
|
||||
int pageCount = this.downExcelGetListPages(query) + 1;
|
||||
|
|
@ -2250,7 +2271,7 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
|
|||
|
||||
this.updateMaterialPurchaseInfo(filterList);
|
||||
}
|
||||
log.info("获取物料的最近出库时间、最近采购价格、最近采购日期结束");
|
||||
log.info("获取物料的最近出库时间、最近采购价格、最近采购日期、物料价格结束");
|
||||
}
|
||||
|
||||
private void updateMaterialPurchaseInfo(List<MaterialMainEntity> filterList) {
|
||||
|
|
|
|||
|
|
@ -57,8 +57,16 @@ public class SapInfoService {
|
|||
System.out.println("获取sap最近库存时间数据错误");
|
||||
}
|
||||
}, futureTaskPool);
|
||||
CompletableFuture<Void> task6 = CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
initSapPriceInfo(result);
|
||||
} catch (Exception e) {
|
||||
System.out.println("获取sap物料价格数据错误".concat(e.getMessage()));
|
||||
}
|
||||
}, futureTaskPool);
|
||||
task4.join();
|
||||
task5.join();
|
||||
task6.join();
|
||||
}
|
||||
|
||||
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) {
|
||||
CompletableFuture<Void> task = CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue