|
@@ -18,10 +18,12 @@ import com.fjhx.purchase.service.invoice.InvoiceDetailsService;
|
|
|
import com.fjhx.purchase.service.invoice.InvoiceService;
|
|
|
import com.fjhx.supply.entity.supplier.po.SupplierInfo;
|
|
|
import com.fjhx.supply.service.supplier.SupplierInfoService;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
+import com.ruoyi.system.service.ISysDeptService;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -51,6 +53,9 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, Invoice> impl
|
|
|
@Autowired
|
|
|
private SupplierInfoService supplierInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService deptService;
|
|
|
+
|
|
|
|
|
|
* 分页
|
|
|
*
|
|
@@ -77,17 +82,30 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, Invoice> impl
|
|
|
wrapper.orderByDesc("t1", Invoice::getCreateTime);
|
|
|
Page<InvoiceVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
List<InvoiceVo> list = page.getRecords();
|
|
|
- if (CollectionUtils.isNotEmpty(list)) {
|
|
|
- List<Long> supplyIds = list.stream().map(InvoiceVo::getSupplyId).collect(Collectors.toList());
|
|
|
- List<SupplierInfo> supplierInfoList = supplierInfoService.list(Wrappers.<SupplierInfo>query().lambda().in(SupplierInfo::getId, supplyIds));
|
|
|
- Map<Long, List<SupplierInfo>> supplyMap = supplierInfoList.stream().distinct().collect(Collectors.groupingBy(SupplierInfo::getId));
|
|
|
- if (MapUtils.isNotEmpty(supplyMap)) {
|
|
|
- for (InvoiceVo p : list) {
|
|
|
- List<SupplierInfo> supplys = supplyMap.getOrDefault(p.getSupplyId(), null);
|
|
|
- p.setSupplyName(supplys == null ? null : supplys.get(0).getName());
|
|
|
- }
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(list)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> supplyIds = list.stream().map(InvoiceVo::getSupplyId).collect(Collectors.toList());
|
|
|
+ List<SupplierInfo> supplierInfoList = supplierInfoService.list(Wrappers.<SupplierInfo>query().lambda().in(SupplierInfo::getId, supplyIds));
|
|
|
+ Map<Long, List<SupplierInfo>> supplyMap = supplierInfoList.stream().distinct().collect(Collectors.groupingBy(SupplierInfo::getId));
|
|
|
+ if (MapUtils.isNotEmpty(supplyMap)) {
|
|
|
+ for (InvoiceVo p : list) {
|
|
|
+ List<SupplierInfo> supplys = supplyMap.getOrDefault(p.getSupplyId(), null);
|
|
|
+ p.setSupplyName(supplys == null ? null : supplys.get(0).getName());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ List<SysDept> companyList = deptService.list();
|
|
|
+ Map<Long, String> companyMap = companyList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
|
|
|
+
|
|
|
+ for (InvoiceVo record : list) {
|
|
|
+
|
|
|
+ record.setCompanyName(companyMap.get(record.getCompanyId()));
|
|
|
+ }
|
|
|
+
|
|
|
return page;
|
|
|
}
|
|
|
|
|
@@ -125,8 +143,11 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, Invoice> impl
|
|
|
@DSTransactional
|
|
|
public void add(Invoice invoice) {
|
|
|
|
|
|
+
|
|
|
Long companyId = SecurityUtils.getCompanyId();
|
|
|
- invoice.setCompanyId(companyId);
|
|
|
+ if (ObjectUtils.isEmpty(invoice.getCompanyId())) {
|
|
|
+ invoice.setCompanyId(companyId);
|
|
|
+ }
|
|
|
this.save(invoice);
|
|
|
List<InvoiceDetails> invoiceDetailsList = invoice.getInvoiceDetailsList();
|
|
|
if (CollectionUtils.isNotEmpty(invoiceDetailsList)) {
|