|
@@ -19,7 +19,6 @@ import com.fjhx.common.service.documentary.GetDocumentaryBusinessTemplate;
|
|
import com.fjhx.customer.service.customer.CustomerService;
|
|
import com.fjhx.customer.service.customer.CustomerService;
|
|
import com.fjhx.item.entity.product.vo.ProductInfoVo;
|
|
import com.fjhx.item.entity.product.vo.ProductInfoVo;
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
-import com.fjhx.purchase.entity.arrival.po.Arrival;
|
|
|
|
import com.fjhx.purchase.entity.invoice.vo.InvoiceDetailsVo;
|
|
import com.fjhx.purchase.entity.invoice.vo.InvoiceDetailsVo;
|
|
import com.fjhx.purchase.entity.pay.vo.PayDetailVo;
|
|
import com.fjhx.purchase.entity.pay.vo.PayDetailVo;
|
|
import com.fjhx.purchase.entity.purchase.bo.PurchaseDocumentaryBo;
|
|
import com.fjhx.purchase.entity.purchase.bo.PurchaseDocumentaryBo;
|
|
@@ -41,7 +40,6 @@ import com.fjhx.purchase.service.purchase.PurchaseDetailService;
|
|
import com.fjhx.purchase.service.purchase.PurchaseService;
|
|
import com.fjhx.purchase.service.purchase.PurchaseService;
|
|
import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
|
|
import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
|
|
import com.fjhx.purchase.service.subscribe.SubscribeService;
|
|
import com.fjhx.purchase.service.subscribe.SubscribeService;
|
|
-import com.fjhx.purchase.util.code.CodeEnum;
|
|
|
|
import com.fjhx.supply.entity.supplier.po.SupplierInfo;
|
|
import com.fjhx.supply.entity.supplier.po.SupplierInfo;
|
|
import com.fjhx.supply.service.supplier.SupplierInfoService;
|
|
import com.fjhx.supply.service.supplier.SupplierInfoService;
|
|
import com.fjhx.wms.entity.warehouse.po.Warehouse;
|
|
import com.fjhx.wms.entity.warehouse.po.Warehouse;
|
|
@@ -163,7 +161,37 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
|
|
if (ObjectUtils.isNotEmpty(dto.getPayStatus())) {
|
|
if (ObjectUtils.isNotEmpty(dto.getPayStatus())) {
|
|
wrapper.eq("p", Purchase::getPayStatus, dto.getPayStatus());
|
|
wrapper.eq("p", Purchase::getPayStatus, dto.getPayStatus());
|
|
}
|
|
}
|
|
- wrapper.eq("p", Purchase::getCode, dto.getKeyword());//根据采购单号关键字搜索
|
|
|
|
|
|
+
|
|
|
|
+ //采购单号 供应商 采购人
|
|
|
|
+ if (ObjectUtils.isNotEmpty(dto.getKeyword())) {
|
|
|
|
+ //供应商
|
|
|
|
+ List<Long> supplierInfoIds = supplierInfoService.listObject(SupplierInfo::getId, q -> q.eq(SupplierInfo::getName, dto.getKeyword()));
|
|
|
|
+ wrapper.and(q -> q.like("json_unquote(p.victoriatourist_json -> '$.contractCode')", dto.getKeyword())
|
|
|
|
+ .or().in("p", Purchase::getSupplyId, supplierInfoIds)
|
|
|
|
+ .or().like("p", Purchase::getPurchaseName, dto.getKeyword())
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ //高级检索
|
|
|
|
+ //采购单号
|
|
|
|
+ if (ObjectUtils.isNotEmpty(dto.getContractCode())) {
|
|
|
|
+ wrapper.like("json_unquote(p.victoriatourist_json -> '$.contractCode')", dto.getContractCode());
|
|
|
|
+ }
|
|
|
|
+ //供应商
|
|
|
|
+ wrapper.eq("p", Purchase::getSupplyId, dto.getSupplyId());
|
|
|
|
+ //收货仓库
|
|
|
|
+ if (ObjectUtils.isNotEmpty(dto.getReceiptWarehouseId())) {
|
|
|
|
+ wrapper.like("json_unquote(p.victoriatourist_json -> '$.receiptWarehouseId')", dto.getReceiptWarehouseId());
|
|
|
|
+ }
|
|
|
|
+ //采购金额
|
|
|
|
+ wrapper.ge(Purchase::getAmount, dto.getStartAmount());
|
|
|
|
+ wrapper.le(Purchase::getAmount, dto.getEndAmount());
|
|
|
|
+ //采购人
|
|
|
|
+ wrapper.eq(Purchase::getCreateUser, dto.getPurchaseUserId());
|
|
|
|
+ //采购时间
|
|
|
|
+ wrapper.ge(Purchase::getCreateTime, dto.getPurchaseStartTime());
|
|
|
|
+ wrapper.le(Purchase::getCreateTime, dto.getPurchaseEndTime());
|
|
|
|
+
|
|
|
|
+
|
|
Page<PurchaseVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
Page<PurchaseVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
List<PurchaseVo> list = page.getRecords();
|
|
List<PurchaseVo> list = page.getRecords();
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
@@ -252,9 +280,9 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
|
|
//赋值申购编号
|
|
//赋值申购编号
|
|
PurchaseDetail purchaseDetail = purchaseDetailList.get(0);
|
|
PurchaseDetail purchaseDetail = purchaseDetailList.get(0);
|
|
SubscribeDetail subscribeDetail = subscribeDetailService.getById(purchaseDetail.getSubscribeDetailId());
|
|
SubscribeDetail subscribeDetail = subscribeDetailService.getById(purchaseDetail.getSubscribeDetailId());
|
|
- if(ObjectUtils.isNotEmpty(subscribeDetail)) {
|
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(subscribeDetail)) {
|
|
Subscribe subscribe = subscribeService.getById(subscribeDetail.getSubscribeId());
|
|
Subscribe subscribe = subscribeService.getById(subscribeDetail.getSubscribeId());
|
|
- if(ObjectUtils.isNotEmpty(subscribe)) {
|
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(subscribe)) {
|
|
result.setSubscribeCode(subscribe.getCode());
|
|
result.setSubscribeCode(subscribe.getCode());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -293,7 +321,7 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
|
|
PurchaseService purchaseService = SpringUtil.getBean(PurchaseService.class);
|
|
PurchaseService purchaseService = SpringUtil.getBean(PurchaseService.class);
|
|
PurchaseDetailService purchaseDetailService = SpringUtil.getBean(PurchaseDetailService.class);
|
|
PurchaseDetailService purchaseDetailService = SpringUtil.getBean(PurchaseDetailService.class);
|
|
// purchase.setCode(CodeEnum.PURCHASE.getCode());
|
|
// purchase.setCode(CodeEnum.PURCHASE.getCode());
|
|
- purchase.setCode(codingRuleService.createCode(CodingRuleEnum.PURCHASE.getKey(),null));
|
|
|
|
|
|
+ purchase.setCode(codingRuleService.createCode(CodingRuleEnum.PURCHASE.getKey(), null));
|
|
purchase.setPurchaseStatus(PurchaseStatusEnum.UNDER_REVIEW.getKey());
|
|
purchase.setPurchaseStatus(PurchaseStatusEnum.UNDER_REVIEW.getKey());
|
|
purchaseService.save(purchase);
|
|
purchaseService.save(purchase);
|
|
if (CollectionUtils.isNotEmpty(purchase.getPurchaseDetailList())) {
|
|
if (CollectionUtils.isNotEmpty(purchase.getPurchaseDetailList())) {
|
|
@@ -353,21 +381,21 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
|
|
@Override
|
|
@Override
|
|
public Page<PurchaseDto> paymentBill(PurchaseSelectDto purchaseDto) {
|
|
public Page<PurchaseDto> paymentBill(PurchaseSelectDto purchaseDto) {
|
|
QueryWrapper<Object> query = Wrappers.query();
|
|
QueryWrapper<Object> query = Wrappers.query();
|
|
- query.eq(ObjectUtil.isNotEmpty(purchaseDto.getSupplyId()),"pu.supply_id",purchaseDto.getSupplyId());
|
|
|
|
- query.eq(ObjectUtil.isNotEmpty(purchaseDto.getPayStatus()),"pu.pay_status",purchaseDto.getPayStatus());
|
|
|
|
- query.like(StringUtils.isNotEmpty(purchaseDto.getKeyword()),"pu.code",purchaseDto.getKeyword());
|
|
|
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(purchaseDto.getSupplyId()), "pu.supply_id", purchaseDto.getSupplyId());
|
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(purchaseDto.getPayStatus()), "pu.pay_status", purchaseDto.getPayStatus());
|
|
|
|
+ query.like(StringUtils.isNotEmpty(purchaseDto.getKeyword()), "pu.code", purchaseDto.getKeyword());
|
|
query.groupBy("pu.id");
|
|
query.groupBy("pu.id");
|
|
//查询采购信息与已收发票
|
|
//查询采购信息与已收发票
|
|
- Page<PurchaseDto> page = baseMapper.paymentBill(purchaseDto.getPage(),query);
|
|
|
|
|
|
+ Page<PurchaseDto> page = baseMapper.paymentBill(purchaseDto.getPage(), query);
|
|
List<PurchaseDto> records = page.getRecords();
|
|
List<PurchaseDto> records = page.getRecords();
|
|
- if (records.size()==0){
|
|
|
|
|
|
+ if (records.size() == 0) {
|
|
return page;
|
|
return page;
|
|
}
|
|
}
|
|
//获取到所有的采购订单ID
|
|
//获取到所有的采购订单ID
|
|
List<Long> ids = records.stream().map(purchaseDto1 -> purchaseDto1.getId()).collect(Collectors.toList());
|
|
List<Long> ids = records.stream().map(purchaseDto1 -> purchaseDto1.getId()).collect(Collectors.toList());
|
|
QueryWrapper<Object> wrapper = Wrappers.query();
|
|
QueryWrapper<Object> wrapper = Wrappers.query();
|
|
- wrapper.in("sw.business_id",ids);
|
|
|
|
- wrapper.eq("sw.type",1);
|
|
|
|
|
|
+ wrapper.in("sw.business_id", ids);
|
|
|
|
+ wrapper.eq("sw.type", 1);
|
|
wrapper.groupBy("sw.business_id");
|
|
wrapper.groupBy("sw.business_id");
|
|
//查询到货金额(已入库的采购数量*采购单价)
|
|
//查询到货金额(已入库的采购数量*采购单价)
|
|
List<PurchaseDto> purchaseDtos = baseMapper.arrivalAmount(wrapper);
|
|
List<PurchaseDto> purchaseDtos = baseMapper.arrivalAmount(wrapper);
|
|
@@ -376,8 +404,8 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
|
|
|
|
|
|
//查询已付款金额()
|
|
//查询已付款金额()
|
|
QueryWrapper<Object> queryWrapper = Wrappers.query();
|
|
QueryWrapper<Object> queryWrapper = Wrappers.query();
|
|
- queryWrapper.in("pd.purchase_id",ids);
|
|
|
|
- queryWrapper.eq("p.status",30);
|
|
|
|
|
|
+ queryWrapper.in("pd.purchase_id", ids);
|
|
|
|
+ queryWrapper.eq("p.status", 30);
|
|
queryWrapper.groupBy("pd.purchase_id");
|
|
queryWrapper.groupBy("pd.purchase_id");
|
|
List<PurchaseDto> purchaseDtos1 = baseMapper.paidAmount(queryWrapper);
|
|
List<PurchaseDto> purchaseDtos1 = baseMapper.paidAmount(queryWrapper);
|
|
Map<Long, List<PurchaseDto>> paidMap = purchaseDtos1.stream().collect(Collectors.groupingBy(PurchaseDto::getId));
|
|
Map<Long, List<PurchaseDto>> paidMap = purchaseDtos1.stream().collect(Collectors.groupingBy(PurchaseDto::getId));
|
|
@@ -392,14 +420,14 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
|
|
//已付款金额币种默认合同币种
|
|
//已付款金额币种默认合同币种
|
|
record.setPaidCurrency(record.getCurrency());
|
|
record.setPaidCurrency(record.getCurrency());
|
|
//赋值到货金额
|
|
//赋值到货金额
|
|
- List<PurchaseDto> arrivalList= arrivalMap.get(record.getId());
|
|
|
|
- if (ObjectUtils.isNotEmpty(arrivalList)){
|
|
|
|
|
|
+ List<PurchaseDto> arrivalList = arrivalMap.get(record.getId());
|
|
|
|
+ if (ObjectUtils.isNotEmpty(arrivalList)) {
|
|
record.setArrivalAmount(arrivalList.get(0).getAmount());
|
|
record.setArrivalAmount(arrivalList.get(0).getAmount());
|
|
}
|
|
}
|
|
|
|
|
|
//赋值已付款金额
|
|
//赋值已付款金额
|
|
List<PurchaseDto> paidList = paidMap.get(record.getId());
|
|
List<PurchaseDto> paidList = paidMap.get(record.getId());
|
|
- if (ObjectUtils.isNotEmpty(paidList)){
|
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(paidList)) {
|
|
record.setPaidAmount(paidList.get(0).getAmount());
|
|
record.setPaidAmount(paidList.get(0).getAmount());
|
|
record.setPaidCurrency(paidList.get(0).getCurrency());
|
|
record.setPaidCurrency(paidList.get(0).getCurrency());
|
|
}
|
|
}
|