Ver código fonte

收料单入库明细指定仓库还原

koul 3 anos atrás
pai
commit
a9e47e7d72

+ 13 - 17
src/main/java/com/uas/eis/service/Impl/MESServiceImpl.java

@@ -72,9 +72,11 @@ public class MESServiceImpl implements MESService {
         String type="其它入库单";
         String type="其它入库单";
         String djcaller="ProdInOut!OtherIn";
         String djcaller="ProdInOut!OtherIn";
         String sellerName="";
         String sellerName="";
+        String whcode="";
         for (int i = 0; i <jsonArray.size() ; i++) {
         for (int i = 0; i <jsonArray.size() ; i++) {
             JSONObject jsonObject = JSON.parseObject(StringUtil.nvl(jsonArray.get(i), ""));
             JSONObject jsonObject = JSON.parseObject(StringUtil.nvl(jsonArray.get(i), ""));
             String mesCode = StringUtil.nvl(jsonObject.get("mesCode"),"");
             String mesCode = StringUtil.nvl(jsonObject.get("mesCode"),"");
+            whcode= StringUtil.nvl(jsonObject.get("whNo"), "");
             if ("".equals(mesCode)){
             if ("".equals(mesCode)){
                 return ApiResponse.failRsp("10011",requestId,"ERP单据编号不能为空!");
                 return ApiResponse.failRsp("10011",requestId,"ERP单据编号不能为空!");
             }
             }
@@ -140,15 +142,16 @@ public class MESServiceImpl implements MESService {
             if (compare<0){
             if (compare<0){
                 return ApiResponse.failRsp("10018",requestId,"物料:"+itemNo+",收料数量:"+qty+"少于ERP收料单数量:"+vadQty+",不允许入库!");
                 return ApiResponse.failRsp("10018",requestId,"物料:"+itemNo+",收料数量:"+qty+"少于ERP收料单数量:"+vadQty+",不允许入库!");
             }
             }
-            String whcode= StringUtil.nvl(json.get("vad_whcode"), "");
-            if ("".equals(whcode)){
-                return ApiResponse.failRsp("10015",requestId,"MES仓库编号不能为空!");
-            }
-            int coun = 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 (coun<=0){
-                return ApiResponse.failRsp("10016",requestId,"MES仓库编号在ERP没有对应关系,请联系管理员新增!");
-            }
         }
         }
+        if ("".equals(whcode)){
+            return ApiResponse.failRsp("10015",requestId,"MES仓库编号不能为空!");
+        }
+        int coun = 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 (coun<=0){
+            return ApiResponse.failRsp("10016",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", "ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whcode + "'");
+
         int piid =0;
         int piid =0;
         Employee employee = baseDao.getJdbcTemplate().queryForObject("select * from employee where em_name=?",
         Employee employee = baseDao.getJdbcTemplate().queryForObject("select * from employee where em_name=?",
                 new BeanPropertyRowMapper<Employee>(Employee.class), sellerName);
                 new BeanPropertyRowMapper<Employee>(Employee.class), sellerName);
@@ -159,15 +162,8 @@ public class MESServiceImpl implements MESService {
         transferRepository.transferDetail(caller, vaid, key,employee);
         transferRepository.transferDetail(caller, vaid, key,employee);
         if (piid != 0) {
         if (piid != 0) {
             baseDao.execute("delete from prodiodetail where nvl(pd_inqty,0)<=0 and pd_piid="+piid);
             baseDao.execute("delete from prodiodetail where nvl(pd_inqty,0)<=0 and pd_piid="+piid);
-            //更新仓库
-            for (int i = 0; i <array.size() ; i++) {
-                JSONObject json = JSON.parseObject(StringUtil.nvl(array.get(i), ""));
-                String itemNo = StringUtil.nvl(json.get("itemNo"), "");
-                String whcode= StringUtil.nvl(json.get("vad_whcode"), "");
-                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", "ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whcode + "'");
-                baseDao.updateByCondition("prodiodetail", "pd_whcode='"+warehouses[0]+"',pd_whname='"+warehouses[1]+"'", "pd_prodcode='"+itemNo+"' and pd_piid=" + piid);
-            }
-            //baseDao.updateByCondition("prodinout", "pi_whcode='"+warehouses[0]+"',pi_whname='"+warehouses[1]+"'","pi_id=" + piid);
+            baseDao.updateByCondition("prodiodetail", "pd_whcode='"+warehouses[0]+"',pd_whname='"+warehouses[1]+"'", "pd_piid=" + piid);
+            baseDao.updateByCondition("prodinout", "pi_whcode='"+warehouses[0]+"',pi_whname='"+warehouses[1]+"'", "pi_id=" + piid);
             baseDao.execute("update prodiodetail set pd_prodid=(select pr_id from product where pd_prodcode=pr_code) where pd_piid=" + piid
             baseDao.execute("update prodiodetail set pd_prodid=(select pr_id from product where pd_prodcode=pr_code) where pd_piid=" + piid
                     + " and nvl(pd_prodcode,' ')<>' '");
                     + " and nvl(pd_prodcode,' ')<>' '");
             baseDao.execute("update prodiodetail set pd_whid=(select wh_id from warehouse where wh_code=pd_whcode) where pd_piid=" + piid
             baseDao.execute("update prodiodetail set pd_whid=(select wh_id from warehouse where wh_code=pd_whcode) where pd_piid=" + piid