Browse Source

出货单转退货单带物料默认仓库

guq 7 years ago
parent
commit
5f3086f910

+ 19 - 0
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/ProdInOutServiceImpl.java

@@ -527,6 +527,13 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
                 targetPid.setPd_inqty(pdOutqty-pdYqty);
                 targetPid.setPd_total((pdOutqty-pdYqty)*pdSendPrice);
                 targetPid.setPd_nettotal((pdOutqty-pdYqty)*(pdSendPrice/(1+pdTaxrate/100)));
+                //获取物料默认仓库
+                Map<String, Object> warehouse = getWareHouseByCode(sourcePid.getPd_prodcode());
+                if (null != warehouse) {
+                    targetPid.setPd_whid(warehouse.get("pr_whid") == null ? 0 : Long.valueOf(warehouse.get("pr_whid").toString()));
+                    targetPid.setPd_whcode(warehouse.get("pr_whcode") == null ? null : warehouse.get("pr_whcode").toString());
+                    targetPid.setPd_whname(warehouse.get("pr_whname") == null ? null : warehouse.get("pr_whname").toString());
+                }
                 prodIODetailMapper.insertSelective(targetPid);
                 //更新已转数
                 sourcePid.setPd_yqty(pdOutqty);
@@ -548,6 +555,18 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
 
     }
 
+    private Map<String, Object> getWareHouseByCode(String code) {
+        if (StringUtils.isEmpty(code)) {
+            return null;
+        }
+        Long companyId = BaseContextHolder.getCompanyId();
+        List<HashMap<String, Object>> list = prodInOutMapper.getWareHouseByCode(code, companyId);
+        if (null != list && list.size() > 0) {
+            return list.get(0);
+        }
+        return null;
+    }
+
     @Override
     @Transactional
     public DocBaseDTO close(Long id) {