|
|
@ -18,6 +18,7 @@ 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.pojo.purchasenewproduct.PurchasenewProductVo; |
|
|
|
import com.wh.service.api.prodstock.ProdStockService; |
|
|
|
import com.wh.service.purchasenew.PurchasenewService; |
|
|
|
import com.wh.service.purchasenewproduct.PurchasenewProductService; |
|
|
@ -53,7 +54,8 @@ public class InStorehouseMainService extends MybatisBaseService<InStorehouseMai |
|
|
|
private PurchasenewService purchasenewService; |
|
|
|
@Autowired |
|
|
|
private PurchasenewProductService purchasenewProductService; |
|
|
|
@Transactional |
|
|
|
@Autowired |
|
|
|
private InStorehouseMainService inStorehouseMainService; |
|
|
|
public ResultBean addInStorehouse(InStoreHouseMainDto inStoreHouseMainDto) { |
|
|
|
ResultBean<Object> r = ResultBean.fireFail(); |
|
|
|
if(inStoreHouseMainDto==null){ |
|
|
@ -62,21 +64,58 @@ public class InStorehouseMainService extends MybatisBaseService<InStorehouseMai |
|
|
|
if(StringUtils.isBlank(inStoreHouseMainDto.getNo())){ |
|
|
|
return r.setMsg("申请单编号不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
QueryWrapper<Purchasenew> purchasenewWrapper = new QueryWrapper<>(); |
|
|
|
purchasenewWrapper.eq("purchase_no",inStoreHouseMainDto.getNo()); |
|
|
|
List<Purchasenew> list1 = purchasenewService.list(purchasenewWrapper); |
|
|
|
if(list1==null||list1.size()==0){ |
|
|
|
return r.setMsg("申请单不存在"); |
|
|
|
} |
|
|
|
Purchasenew purchasenew = list1.get(0); |
|
|
|
PurchasenewDto dto =new PurchasenewDto(); |
|
|
|
BeanUtil.copyProperties(purchasenew,dto); |
|
|
|
String purchaseSid=purchasenew.getSid(); |
|
|
|
QueryWrapper<InStorehouseMain> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.eq("no",inStoreHouseMainDto.getNo()); |
|
|
|
if(baseMapper.selectCount(queryWrapper) != 0){ |
|
|
|
return r.setMsg("申请单编号已经存在"); |
|
|
|
queryWrapper.eq("purchase_sid",purchasenew.getSid()); |
|
|
|
List<InStorehouseMain> inStorehouseMains = baseMapper.selectList(queryWrapper); |
|
|
|
if(inStorehouseMains!=null&&inStorehouseMains.size()>0){ |
|
|
|
return r.setMsg("申请单编号已经入库"); |
|
|
|
} |
|
|
|
List<PurchasenewProductVo> purchasenewProductVos = |
|
|
|
purchasenewProductService.fetchDetailsVoByPurchaseSid(purchaseSid); |
|
|
|
List<PurchasenewProductDto> products=new ArrayList<>(); |
|
|
|
for (PurchasenewProductVo purchasenewProductVo : purchasenewProductVos) { |
|
|
|
PurchasenewProductDto d=new PurchasenewProductDto(); |
|
|
|
BeanUtil.copyProperties(purchasenewProductVo,d); |
|
|
|
products.add(d); |
|
|
|
} |
|
|
|
dto.setProducts(products); |
|
|
|
saveOrUpdateByPurchaseSid(dto,purchaseSid); |
|
|
|
// InStorehouseMain in=new InStorehouseMain();
|
|
|
|
// BeanUtils.copyProperties(inStoreHouseMainDto,in);
|
|
|
|
// List<InStorehouseListing> list = inStoreHouseMainDto.getList();
|
|
|
|
// if(list==null||list.size()==0){
|
|
|
|
// return r.setMsg("商品不能为空");
|
|
|
|
// }
|
|
|
|
// //申请单主表信息
|
|
|
|
// baseMapper.insert(in);
|
|
|
|
// addListing(in, list);
|
|
|
|
return ResultBean.fireSuccess().setMsg("添加成功"); |
|
|
|
} |
|
|
|
@Transactional |
|
|
|
public ResultBean addInStorehouses(InStoreHouseMainDto inStoreHouseMainDto) { |
|
|
|
ResultBean<Object> r = ResultBean.fireFail(); |
|
|
|
|
|
|
|
InStorehouseMain in=new InStorehouseMain(); |
|
|
|
BeanUtils.copyProperties(inStoreHouseMainDto,in); |
|
|
|
List<InStorehouseListing> list = inStoreHouseMainDto.getList(); |
|
|
|
if(list==null||list.size()==0){ |
|
|
|
return r.setMsg("商品不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
//申请单主表信息
|
|
|
|
baseMapper.insert(in); |
|
|
|
addListing(in, list); |
|
|
|
purchasenewService.updateStateToInputBySid(in.getPurchaseSid()); |
|
|
|
return ResultBean.fireSuccess().setMsg("添加成功"); |
|
|
|
|
|
|
|
} |
|
|
|
public PagerVo<InStoreHouseMainVo> listPage(PagerQuery<InStorehouseMainQuery> pq) { |
|
|
|
InStorehouseMainQuery query = pq.getParams(); |
|
|
@ -271,7 +310,7 @@ public class InStorehouseMainService extends MybatisBaseService<InStorehouseMai |
|
|
|
}); |
|
|
|
inStoreHouseMainDto.setList(list); |
|
|
|
inStoreHouseMainDto.setPurchaseSid(purchaseSid);//采购申请单的sid
|
|
|
|
addInStorehouse(inStoreHouseMainDto); |
|
|
|
addInStorehouses(inStoreHouseMainDto); |
|
|
|
return r.success(); |
|
|
|
} |
|
|
|
|
|
|
|