|
|
@ -1,15 +1,26 @@ |
|
|
|
package com.wh.service.api.instorehouse; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
import com.wh.api.Api; |
|
|
|
import com.wh.mapper.api.instorehouse.InStorehouseMainMapper; |
|
|
|
import com.wh.mapper.initial.LocationMapper; |
|
|
|
import com.wh.pojo.InStorehouse; |
|
|
|
import com.wh.pojo.Location; |
|
|
|
import com.wh.pojo.Purchase; |
|
|
|
import com.wh.pojo.Receiving; |
|
|
|
import com.wh.pojo.api.*; |
|
|
|
import com.wh.pojo.purchasenew.Purchasenew; |
|
|
|
import com.wh.pojo.purchasenew.PurchasenewDto; |
|
|
|
import com.wh.pojo.purchasenewproduct.PurchasenewProduct; |
|
|
|
import com.wh.pojo.purchasenewproduct.PurchasenewProductDto; |
|
|
|
import com.wh.service.api.prodstock.ProdStockService; |
|
|
|
import com.wh.service.purchasenew.PurchasenewService; |
|
|
|
import com.wh.service.purchasenewproduct.PurchasenewProductService; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
@ -36,6 +47,12 @@ public class InStorehouseMainService extends MybatisBaseService<InStorehouseMai |
|
|
|
private InStorehouseListingService inStorehouseListingService; |
|
|
|
@Autowired |
|
|
|
private ProdStockService prodStockService; |
|
|
|
@Autowired |
|
|
|
private LocationMapper locationMapper; |
|
|
|
@Autowired |
|
|
|
private PurchasenewService purchasenewService; |
|
|
|
@Autowired |
|
|
|
private PurchasenewProductService purchasenewProductService; |
|
|
|
@Transactional |
|
|
|
public ResultBean addInStorehouse(InStoreHouseMainDto inStoreHouseMainDto) { |
|
|
|
ResultBean<Object> r = ResultBean.fireFail(); |
|
|
@ -160,6 +177,7 @@ public class InStorehouseMainService extends MybatisBaseService<InStorehouseMai |
|
|
|
prodStock.setCusterSid(l.getCusterSid());// varchar 64 客户Sid(企业)
|
|
|
|
prodStock.setStoreHouseSid(l.getStoreHouseSid());// varchar 64 仓库Sid
|
|
|
|
prodStock.setStoreHouseName(l.getStoreHouseName());// varchar 100 仓库名称
|
|
|
|
prodStock.setProSid(l.getProSid()); |
|
|
|
prodStockService.insert(prodStock); |
|
|
|
} |
|
|
|
|
|
|
@ -176,6 +194,7 @@ public class InStorehouseMainService extends MybatisBaseService<InStorehouseMai |
|
|
|
stockQuery.setCusterSid(l.getCusterSid()); |
|
|
|
stockQuery.setProModel(l.getProModel()); |
|
|
|
stockQuery.setProName(l.getProName()); |
|
|
|
stockQuery.setProSid(l.getProSid()); |
|
|
|
pq.setParams(stockQuery); |
|
|
|
PagerVo<ProdStock> proStocks = prodStockService.getProStocks(pq); |
|
|
|
return proStocks; |
|
|
@ -266,4 +285,116 @@ public class InStorehouseMainService extends MybatisBaseService<InStorehouseMai |
|
|
|
baseMapper.deleteByMap(params); |
|
|
|
return r.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public void deleteByPurchaseSid(String sid) { |
|
|
|
Map<String,Object> params=new HashMap<>(); |
|
|
|
params.put("purchase_sid",sid); |
|
|
|
List<InStorehouseMain> inStorehouseMains = baseMapper.selectByMap(params); |
|
|
|
if(inStorehouseMains!=null&&inStorehouseMains.size()>0){ |
|
|
|
InStorehouseMain inStorehouseMain = inStorehouseMains.get(0); |
|
|
|
deleteByMainSid(inStorehouseMain.getSid()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取所有未入库的采购订单编号和仓库信息 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Map<String, Object> getQuery(InStorehouseMainQuery query) { |
|
|
|
// Purchasenew purchase = new Purchasenew();
|
|
|
|
// if (org.springframework.util.StringUtils.hasLength(inStorehouse.getReceivingId())){
|
|
|
|
// Receiving receivingAble = receivingMapper.selectById(inStorehouse.getReceivingId());
|
|
|
|
// purchase = purchaseMapper.selectById(receivingAble.getPurchaseId());
|
|
|
|
// }
|
|
|
|
|
|
|
|
QueryWrapper<Receiving> receivingQueryWrapper = new QueryWrapper<>(); |
|
|
|
receivingQueryWrapper.eq("status","已审核") |
|
|
|
.select("receiving_id"); |
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<Location> locationQueryWrapper = new QueryWrapper<>(); |
|
|
|
locationQueryWrapper.eq("status","空闲") |
|
|
|
.eq("type","入库区") |
|
|
|
//.eq(org.springframework.util.StringUtils.hasLength(purchase.getStorehouse()),"storehouse",purchase.getStorehouse())
|
|
|
|
.select("location_id"); |
|
|
|
|
|
|
|
//List<Receiving> receivingList = receivingMapper.selectList(receivingQueryWrapper);
|
|
|
|
Map<String,Object> params=new HashMap<>(); |
|
|
|
params.put("status","1");//未入库的采购订单
|
|
|
|
params.put("cust_id",query.getCusterSid());//未入库的采购订单
|
|
|
|
List<Purchasenew> purchasenews = purchasenewService.listByMap(params); |
|
|
|
List<Location> locationList = locationMapper.selectList(locationQueryWrapper); |
|
|
|
|
|
|
|
List<Map<String,String>> receivingIdList = new ArrayList<>(); |
|
|
|
List<Map<String,String>> locationIdList = new ArrayList<>(); |
|
|
|
|
|
|
|
for (Purchasenew receiving : purchasenews){ |
|
|
|
Map<String,String> map=new HashMap<>(); |
|
|
|
map.put("no",receiving.getPurchaseNo()); |
|
|
|
map.put("sid",receiving.getSid()); |
|
|
|
receivingIdList.add(map); |
|
|
|
} |
|
|
|
|
|
|
|
if (locationList != null){ |
|
|
|
for (Location location : locationList){ |
|
|
|
Map<String,String> map=new HashMap<>(); |
|
|
|
map.put("locationId",location.getLocationId()); |
|
|
|
map.put("locationName",location.getName()); |
|
|
|
locationIdList.add(map); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
map.put("receivingIdList",receivingIdList); |
|
|
|
map.put("locationIdList",locationIdList); |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean addInStorehouseByPurchase(PurchaseInStoreHouseParams params) { |
|
|
|
ResultBean<Object> r = ResultBean.fireFail(); |
|
|
|
String purchaseSid = params.getPurchaseSid(); |
|
|
|
String userName = params.getUserName(); |
|
|
|
String storeHouseSid = params.getStoreHouseSid(); |
|
|
|
String storeHouseName = params.getStoreHouseName(); |
|
|
|
|
|
|
|
// Location location = locationMapper.selectById(storeHouseSid);
|
|
|
|
// if(location==null){
|
|
|
|
// return r.setMsg("仓库信息不存在");
|
|
|
|
// }
|
|
|
|
String custerSid = params.getCusterSid(); |
|
|
|
Map<String,Object> param5=new HashMap<>(); |
|
|
|
param5.put("sid",purchaseSid); |
|
|
|
List<Purchasenew> purchasenews = purchasenewService.listByMap(param5); |
|
|
|
if(purchasenews==null||purchasenews.size()==0){ |
|
|
|
return r.setMsg("数据不存在"); |
|
|
|
} |
|
|
|
Purchasenew purchasenew = purchasenews.get(0); |
|
|
|
Map<String,Object> params2=new HashMap<>(); |
|
|
|
params2.put("purchase_sid",purchasenew.getSid()); |
|
|
|
List<InStorehouseMain> inStorehouseMains = baseMapper.selectByMap(params2); |
|
|
|
if(inStorehouseMains.size()>0){ |
|
|
|
return r.setMsg("采购订单已经有入库记录"); |
|
|
|
} |
|
|
|
PurchasenewDto pd=new PurchasenewDto(); |
|
|
|
BeanUtil.copyProperties(purchasenew,pd); |
|
|
|
Map<String,Object> params3=new HashMap<>(); |
|
|
|
params3.put("main_sid",purchasenew.getSid()); |
|
|
|
List<PurchasenewProduct> purchasenewProducts = purchasenewProductService.listByMap(params3); |
|
|
|
if (purchasenewProducts==null||purchasenewProducts.size()==0){ |
|
|
|
return r.setMsg("没有商品信息!"); |
|
|
|
} |
|
|
|
List<PurchasenewProductDto> purchasenewProductDtos =new ArrayList<>(); |
|
|
|
purchasenewProducts.forEach(p->{ |
|
|
|
PurchasenewProductDto ppd=new PurchasenewProductDto(); |
|
|
|
BeanUtil.copyProperties(p,ppd); |
|
|
|
ppd.setStoreHouseSid(storeHouseSid); |
|
|
|
ppd.setStoreHouseName(storeHouseName); |
|
|
|
purchasenewProductDtos.add(ppd); |
|
|
|
}); |
|
|
|
pd.setProducts(purchasenewProductDtos); |
|
|
|
pd.setPurchasePersonSid(custerSid); |
|
|
|
pd.setPurchasePerson(userName); |
|
|
|
saveOrUpdateByPurchaseSid(pd,purchasenew.getSid()); |
|
|
|
purchasenewService.updatePutInStatus(purchasenew.getSid()); |
|
|
|
return r.success(); |
|
|
|
} |
|
|
|
} |
|
|
|