Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
08be4cff54
|
@ -129,6 +129,89 @@ public class OnhandResource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询现存量-思普PLM
|
||||||
|
*
|
||||||
|
* @author mzr
|
||||||
|
* @date 2025/7/24
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("onhandQuerySp")
|
||||||
|
@Consumes("application/json")
|
||||||
|
@Produces("application/json")
|
||||||
|
public JSONString onhandQuerySp(Map<String, Object> paramMap) {
|
||||||
|
if (paramMap == null) {
|
||||||
|
return ResultMessageUtil.exceptionToJSON("传入参数错误,组织条件必输", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
OnhandVO[] onhandVOs = NCLocator.getInstance().lookup(IAPIOnhandQuery.class)
|
||||||
|
.queryOnhandVOByDims(paramMap);
|
||||||
|
// 对数据进行整合组装,返回物料+仓库+数量
|
||||||
|
if (null != onhandVOs && onhandVOs.length > 0) {
|
||||||
|
// 收集所有物料和仓库ID
|
||||||
|
Set<String> materialIds = Arrays.stream(onhandVOs)
|
||||||
|
.map(OnhandVO::getCmaterialvid)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Set<String> warehouseIds = Arrays.stream(onhandVOs)
|
||||||
|
.map(OnhandVO::getCwarehouseid)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// 批量查询物料和仓库信息
|
||||||
|
Map<String, Map<String, Object>> materialInfoMap = new HashMap<>();
|
||||||
|
Map<String, Map<String, Object>> warehouseInfoMap = new HashMap<>();
|
||||||
|
|
||||||
|
String materialSelectFields = MaterialVO.CODE + "," + MaterialVO.NAME;
|
||||||
|
String warehouseSelectFields = StordocVO.CODE + "," + StordocVO.NAME;
|
||||||
|
|
||||||
|
for (String materialId : materialIds) {
|
||||||
|
Map<String, Object> materialMap = this.transferFields(
|
||||||
|
MaterialVO.getDefaultTableName(), materialSelectFields, MaterialVO.PK_MATERIAL, materialId);
|
||||||
|
materialInfoMap.put(materialId, materialMap != null ? materialMap : new HashMap<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String warehouseId : warehouseIds) {
|
||||||
|
Map<String, Object> warehouseMap = this.transferFields(
|
||||||
|
StordocVO.getDefaultTableName(), warehouseSelectFields, StordocVO.PK_STORDOC, warehouseId);
|
||||||
|
warehouseInfoMap.put(warehouseId, warehouseMap != null ? warehouseMap : new HashMap<>());
|
||||||
|
}
|
||||||
|
// 根据物料和仓库分组
|
||||||
|
Map<String, List<OnhandVO>> groupedOnhand = Arrays.stream(onhandVOs)
|
||||||
|
.collect(Collectors.groupingBy(onhandVO -> onhandVO.getPk_org() + "_" + onhandVO.getCmaterialvid() + "_" + onhandVO.getCwarehouseid()));
|
||||||
|
Set<String> keys = groupedOnhand.keySet();
|
||||||
|
JSONArray reArray = new JSONArray();
|
||||||
|
for (String dimkey : keys) {
|
||||||
|
List<OnhandVO> onhandVOList = groupedOnhand.get(dimkey);
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
UFDouble onhandNum = UFDouble.ZERO_DBL;
|
||||||
|
|
||||||
|
String cmaterialvid = onhandVOList.get(0).getCmaterialvid();
|
||||||
|
String cwarehouseid = onhandVOList.get(0).getCwarehouseid();
|
||||||
|
Map<String, Object> goodsMap = materialInfoMap.getOrDefault(cmaterialvid, Collections.emptyMap());
|
||||||
|
Map<String, Object> stordocMap = warehouseInfoMap.getOrDefault(cwarehouseid, Collections.emptyMap());
|
||||||
|
jsonObject.put("materialPk", cmaterialvid);
|
||||||
|
jsonObject.put("materialCode", goodsMap.getOrDefault(MaterialVO.CODE, ""));// 物料编码
|
||||||
|
jsonObject.put("materialName", goodsMap.getOrDefault(MaterialVO.NAME, ""));// 物料名称
|
||||||
|
jsonObject.put("warehousePk", cwarehouseid);
|
||||||
|
jsonObject.put("warehouseCode", stordocMap.getOrDefault(StordocVO.CODE, ""));// 仓库编码
|
||||||
|
jsonObject.put("warehouseName", stordocMap.getOrDefault(StordocVO.NAME, ""));// 仓库名称
|
||||||
|
for (OnhandVO onhandVO : onhandVOList) {
|
||||||
|
onhandNum = onhandNum.add(onhandVO.getNonhandnum());
|
||||||
|
}
|
||||||
|
jsonObject.put("onhandnum", onhandNum);
|
||||||
|
reArray.add(jsonObject);
|
||||||
|
}
|
||||||
|
return ResultMessageUtil.toJSON(reArray, "现存量查询成功!");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return ResultMessageUtil.toJSON(null, "现存量查询成功,无数据!");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResultMessageUtil.exceptionToJSON(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件批量查询现存量
|
* 根据条件批量查询现存量
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue