|
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
@@ -18,6 +19,7 @@ import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.actualControl.billetActual.billetActual.entity.BilletBasicInfo;
|
|
|
+import org.jeecg.modules.actualControl.billetActual.billetActual.service.IBilletBasicInfoService;
|
|
|
import org.jeecg.modules.actualControl.heatsActuals.entity.HeatsActuals;
|
|
|
import org.jeecg.modules.actualControl.heatsActuals.service.IHeatsActualsService;
|
|
|
import org.jeecg.modules.billet.billetAutoTmp.entity.BilletAutoTmp;
|
|
@@ -111,6 +113,9 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
|
|
|
@Autowired
|
|
|
private IBilletAutoTmpService billetAutoTmpService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IBilletBasicInfoService billetBasicInfoService;
|
|
|
+
|
|
|
/**
|
|
|
* 分页列表查询
|
|
|
*
|
|
@@ -155,6 +160,62 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
|
|
|
.filter(bill -> bill.getOutTime() == null || bill.getAmountTotal() > 0) // 仅当 outTime 非空时过滤 0
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
+ // 将 BilletAutoTmp 数据按 storageBillId 进行分组统计
|
|
|
+ Map<String, List<BilletAutoTmp>> collect = billetAutoTmpList.stream()
|
|
|
+ .collect(Collectors.groupingBy(BilletAutoTmp::getStorageBillId));
|
|
|
+ for (StorageBill filteredRecord : filteredRecords) {
|
|
|
+
|
|
|
+ List<BilletAutoTmp> billetAutoTmps = collect.get(filteredRecord.getId());
|
|
|
+
|
|
|
+ Set<String> billetNos = new HashSet<>();
|
|
|
+
|
|
|
+ if(CollectionUtils.isNotEmpty(billetAutoTmps)) {
|
|
|
+ // 1. 从 BilletAutoTmp 里获取所有 billetNo
|
|
|
+ billetNos = billetAutoTmps.stream()
|
|
|
+ .map(BilletAutoTmp::getBilletNo)
|
|
|
+ .filter(Objects::nonNull) // 过滤掉 null 值
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(billetNos)) {
|
|
|
+ // 2. 查询 BilletBasicInfo 获取 assemblyNumber,并去重
|
|
|
+ LambdaQueryWrapper<BilletBasicInfo> billetBasicQuery = new LambdaQueryWrapper<>();
|
|
|
+ billetBasicQuery.in(BilletBasicInfo::getBilletNo, billetNos);
|
|
|
+ List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(billetBasicQuery);
|
|
|
+
|
|
|
+ // 3. 根据 billetNo 进行映射,获取 assemblyNumber
|
|
|
+ Map<String, String> billetToAssemblyMap = billetBasicInfoList.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ BilletBasicInfo::getBilletNo,
|
|
|
+ BilletBasicInfo::getAssemblyNumber,
|
|
|
+ (existing, replacement) -> existing // 遇到重复 billetNo,保留第一个
|
|
|
+ ));
|
|
|
+
|
|
|
+ // 获取当前 StorageBill 关联的 billetNos
|
|
|
+ List<String> relatedBilletNos = billetAutoTmpList.stream()
|
|
|
+ .filter(tmp -> filteredRecord.getId().equals(tmp.getStorageBillId()))
|
|
|
+ .map(BilletAutoTmp::getBilletNo)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 获取对应的 assemblyNumbers,去重并拼接
|
|
|
+ String assemblyNumbers = relatedBilletNos.stream()
|
|
|
+ .map(billetToAssemblyMap::get)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct() // 去重
|
|
|
+ .collect(Collectors.joining(",")); // 拼接
|
|
|
+
|
|
|
+ // **追加到原来的 assemblyNumber**
|
|
|
+ if (StringUtils.isNotBlank(assemblyNumbers)) {
|
|
|
+ if (StringUtils.isNotBlank(filteredRecord.getAssemblyNumber())) {
|
|
|
+ filteredRecord.setAssemblyNumber(filteredRecord.getAssemblyNumber() + "," + assemblyNumbers);
|
|
|
+ } else {
|
|
|
+ filteredRecord.setAssemblyNumber(assemblyNumbers);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
// 更新 total
|
|
|
long total = filteredRecords.size(); // 最终过滤后的总记录数
|
|
@@ -1268,6 +1329,16 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
|
|
|
.orderByDesc(StorageBill::getCreateTime).last("LIMIT 1");
|
|
|
|
|
|
StorageBill latestStorageBill = storageBillService.getOne(queryWrapper);
|
|
|
+ LambdaQueryWrapper<BilletAutoTmp> tmpQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ tmpQueryWrapper.eq(BilletAutoTmp::getStorageBillId, latestStorageBill.getId());
|
|
|
+ List<BilletAutoTmp> billetAutoTmpList = billetAutoTmpService.list(tmpQueryWrapper);
|
|
|
+
|
|
|
+ if(CollectionUtils.isNotEmpty(billetAutoTmpList)){
|
|
|
+
|
|
|
+ latestStorageBill.setAmountTotal(latestStorageBill.getAmountTotal() + billetAutoTmpList.size());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return Result.OK(latestStorageBill);
|
|
|
}
|
|
|
|