|
|
@@ -1479,6 +1479,52 @@ public class MESServiceImpl implements MESService {
|
|
|
return ApiResponse.successRsp("0",requestId,tlpiclass+":"+tlcode+",请在ERP查看!");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ApiResult<String> productWhQty(HttpServletRequest request) {
|
|
|
+ String requestId = request.getHeader("RequestId");
|
|
|
+ JSONObject data = getJsonData(request);
|
|
|
+ if (data!=null){
|
|
|
+ List<Map<String, Object>> maps = new ArrayList<>();
|
|
|
+ //物料
|
|
|
+ String itemNo = StringUtil.nvl(data.get("ItemNo"), "");
|
|
|
+ if ("".equals(itemNo)){
|
|
|
+ return ApiResponse.failRsp("10071",requestId,"物料不能为空!");
|
|
|
+ }
|
|
|
+ //仓库
|
|
|
+ String whCode = StringUtil.nvl(data.get("WhCode"), "");
|
|
|
+ if ("".equals(whCode)) {
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select pw_whcode,sum(nvl(pw_onhand,0)) qty from productwh where pw_prodcode='" + itemNo + "' group by pw_whcode");
|
|
|
+ while (rs.next()){
|
|
|
+ SqlRowList rowSet = baseDao.queryForRowSet("select cd_varchar50_3,cd_varchar50_1 from customtabledetail left join customtable on cd_ctid=ct_id where ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and nvl(cd_varchar50_1,' ')<>' ' and cd_varchar50_3='" + rs.getGeneralString("pw_whcode") + "' order by ct_id desc,cd_id desc");
|
|
|
+ if (rowSet.next()){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("whCode",rowSet.getString("cd_varchar50_1"));
|
|
|
+ map.put("qty",rs.getGeneralDouble("qty"));
|
|
|
+ maps.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ int count = baseDao.getCount("select count(1) from customtabledetail left join customtable on cd_ctid=ct_id where ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whCode + "'");
|
|
|
+ if (count <= 0) {
|
|
|
+ return ApiResponse.failRsp("10072", requestId, "MES仓库编号在ERP没有对应关系,请联系管理员新增!");
|
|
|
+ }
|
|
|
+ Object[] warehouses = baseDao.getFieldsDataByCondition("customtabledetail left join customtable on cd_ctid=ct_id left join Warehouse on cd_varchar50_3=wh_code", "cd_varchar50_3,wh_description,wh_nocost", "ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whCode + "'");
|
|
|
+ Double qty = baseDao.getSummaryByField("productwh", "pw_onhand", "pw_prodcode='" + itemNo + "' and pw_whcode='" + warehouses[0] + "'");
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("whCode", whCode);
|
|
|
+ map.put("qty", qty);
|
|
|
+ maps.add(map);
|
|
|
+ }
|
|
|
+ if (maps==null){
|
|
|
+ return ApiResponse.failRsp("10073",requestId,"未找到数据!");
|
|
|
+ }else {
|
|
|
+ return ApiResponse.successRsp("0", "获取成功!",requestId, JSON.toJSONString(maps));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return ApiResponse.failRsp("10074",requestId,"参数异常!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private Map<String, JSONArray> getData(HttpServletRequest request){
|
|
|
Map<String, JSONArray> map = new HashMap<>();
|
|
|
try {
|