Browse Source

生产领料单如果需求数为0,或者工单里面没有这个料,则不对接过来,并提示

koul 1 year ago
parent
commit
bc89bdd0a9
1 changed files with 37 additions and 18 deletions
  1. 37 18
      src/main/java/com/uas/eis/service/Impl/MESServiceImpl.java

+ 37 - 18
src/main/java/com/uas/eis/service/Impl/MESServiceImpl.java

@@ -817,6 +817,10 @@ public class MESServiceImpl implements MESService {
             if (count4<=0){
                 return ApiResponse.failRsp("10046",requestId,"工单BOM在ERP中不存在,物料编号:"+itemNo+",请联系管理员!");
             }
+            int count5 = baseDao.getCount("select count(1) from MakeMaterial where mm_id in (" + lineId + ") and nvl(mm_qty,0)>0");
+            if (count5<=0){
+                return ApiResponse.failRsp("10047",requestId,"工单BOM在ERP中需求数为0,物料编号:"+itemNo+",请联系管理员!");
+            }
             Object[] data1 = baseDao.getFieldsDataByCondition("MakeMaterial", "mm_detno,mm_maid","mm_id in (" + lineId + ")");
             maid = Integer.parseInt(StringUtil.nvl(data1[1], "0"));
             if(bccode!=null) {
@@ -1443,7 +1447,8 @@ public class MESServiceImpl implements MESService {
         String requestId = request.getHeader("RequestId");
         Map<String, JSONArray> data = getData(request);
         String llcode = null,ma_tasktype=null,llpiclass = "生产领料单", llcaller = "ProdInOut!Picking";
-        int llpiid=0,maid=0;
+        int llpiid=0,maid=0,detno=1;
+        Object[] warehouses=null;
         List<String> sqls = new ArrayList<>();
         JSONArray detail = data.get("detail");
         if(detail!=null&&detail.size()>0){
@@ -1461,6 +1466,37 @@ public class MESServiceImpl implements MESService {
             }else {
                 return ApiResponse.failRsp("10042", requestId, "工单在ERP不存在,请核对!");
             }
+            for (int i = 0; i <detail.size(); i++) {
+                JSONObject object = JSON.parseObject(StringUtil.nvl(detail.get(i), "{}"));
+                Map<Object, Object> map = JSONUtil.toMap(StringUtil.valueOf(object.get("FItemID")));
+                String itemNo = StringUtil.nvl(map.get("FNumber"), "");
+                if ("".equals(itemNo)){
+                    return ApiResponse.failRsp("10043",requestId,"物料不能为空!");
+                }
+                String fAuxQty = StringUtil.nvl(object.get("FAuxQty"), "0");
+                if ("0".equals(fAuxQty)){
+                    return ApiResponse.failRsp("10044",requestId,"实发数量不能为空!");
+                }
+                Map<Object, Object> map1 = JSONUtil.toMap(StringUtil.valueOf(object.get("FSCStockID2")));
+                String whcode = StringUtil.nvl(map1.get("FNumber"), "");
+                if ("".equals(whcode)){
+                    return ApiResponse.failRsp("10045",requestId,"发料仓库不能为空!");
+                }
+                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("10046",requestId,"MES仓库编号在ERP没有对应关系,请联系管理员新增!");
+                }
+                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", "ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whcode + "'");
+                int lineId = Integer.parseInt(StringUtil.nvl(object.get("lineId"), "0"));
+                int count4 = baseDao.getCount("select count(1) from MakeMaterial where mm_id in (" + lineId + ")");
+                if (count4<=0){
+                    return ApiResponse.failRsp("10047",requestId,"工单BOM在ERP中不存在,物料编号:"+itemNo+",请联系管理员!");
+                }
+                int count5 = baseDao.getCount("select count(1) from MakeMaterial where mm_id in (" + lineId + ") and nvl(mm_qty,0)>0");
+                if (count5<=0){
+                    return ApiResponse.failRsp("10047",requestId,"工单BOM在ERP中需求数为0,物料编号:"+itemNo+",请联系管理员!");
+                }
+            }
         }
         JSONArray main = data.get("main");
         for (int i = 0; i <main.size() ; i++) {
@@ -1484,36 +1520,19 @@ public class MESServiceImpl implements MESService {
             sqls.add("insert into prodinout (pi_id,pi_inoutno,pi_class,pi_date,pi_statuscode,pi_status,pi_departmentcode,pi_departmentname,pi_emcode,pi_emname,pi_invostatuscode,pi_invostatus,pi_recordman,pi_recorddate,pi_printstatuscode,pi_printstatus,pi_type,pi_mescode) " +
                     "values ("+llpiid+",'"+llcode+"','"+llpiclass+"',to_date('"+object.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPOST','未过账','"+map1.get("FNumber")+"','"+map1.get("FName")+"','"+map4.get("FNumber")+"','"+map4.get("FName")+"','ENTERING','在录入','"+map5.get("FName")+"',to_date('"+object.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPRINT','未打印','"+map2.get("FName")+"','"+fSelBillNo+"')");
         }
-        int detno=1;
-        Object[] warehouses=null;
         for (int i = 0; i <detail.size(); i++) {
             JSONObject object = JSON.parseObject(StringUtil.nvl(detail.get(i), "{}"));
             Map<Object, Object> map = JSONUtil.toMap(StringUtil.valueOf(object.get("FItemID")));
             String itemNo = StringUtil.nvl(map.get("FNumber"), "");
-            if ("".equals(itemNo)){
-                return ApiResponse.failRsp("10043",requestId,"物料不能为空!");
-            }
             String fAuxQty = StringUtil.nvl(object.get("FAuxQty"), "0");
-            if ("0".equals(fAuxQty)){
-                return ApiResponse.failRsp("10044",requestId,"实发数量不能为空!");
-            }
             Double qty = Double.parseDouble(fAuxQty);
             Map<Object, Object> map1 = JSONUtil.toMap(StringUtil.valueOf(object.get("FSCStockID2")));
             String whcode = StringUtil.nvl(map1.get("FNumber"), "");
-            if ("".equals(whcode)){
-                return ApiResponse.failRsp("10045",requestId,"发料仓库不能为空!");
-            }
             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("10046",requestId,"MES仓库编号在ERP没有对应关系,请联系管理员新增!");
-            }
             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", "ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whcode + "'");
             String ficmoBillNo = StringUtil.nvl(object.get("FICMOBillNo"), "");
             int lineId = Integer.parseInt(StringUtil.nvl(object.get("lineId"), "0"));
             int count4 = baseDao.getCount("select count(1) from MakeMaterial where mm_id in (" + lineId + ")");
-            if (count4<=0){
-                return ApiResponse.failRsp("10047",requestId,"工单BOM在ERP中不存在,物料编号:"+itemNo+",请联系管理员!");
-            }
             Object[] data1 = baseDao.getFieldsDataByCondition("MakeMaterial", "mm_detno,mm_maid","mm_id in (" + lineId + ")");
             maid = Integer.parseInt(StringUtil.nvl(data1[1], "0"));
             sqls.add("insert into prodiodetail (pd_id,pd_piid,pd_inoutno,pd_piclass,pd_pdno,pd_prodcode,pd_outqty,pd_whcode,pd_whname,pd_ordercode,pd_orderdetno,pd_macode,pd_madetno,pd_status) " +