报表导出

This commit is contained in:
2026-05-25 22:33:27 +08:00
parent 62722a9ce7
commit c0fed06eaa
9 changed files with 825 additions and 9 deletions

View File

@@ -7,11 +7,9 @@ import com.rj.dto.hxr.HxrOrderRow;
import com.rj.dto.hxr.HxrOrderSelectResponse;
import com.rj.entity.LbDepartmentUser;
import com.rj.entity.LbOrderRow;
import com.rj.entity.LbUser;
import com.rj.mapper.LbOrderRowMapper;
import com.rj.service.DingTalkRobotService;
import com.rj.service.HxrAdminOrderSelectService;
import com.rj.service.ILbDepartmentUserService;
import com.rj.service.ILbOrderRowService;
import com.rj.service.*;
import com.rj.tenant.TenantContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -303,6 +301,7 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
entities.add(toLbOrderRow(row, tid));
}
fillSellerInfoFromDepartmentUsers(entities, tid);
fillBuyerInfoFromLBtUsers(entities, tid);
int upserted = upsertBatch(entities);
if (upserted < 0) {
result.put("success", false);
@@ -685,6 +684,50 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
}
}
}
@Autowired
private ILbUserService lbUserService;
/**
* 按 buyer_id 关联 lb_department_user.user_id用部门用户的 name、phone 填充买方姓名与电话。
*/
private void fillBuyerInfoFromLBtUsers(List<LbOrderRow> entities, String tenantId) {
if (entities == null || entities.isEmpty()) {
return;
}
Set<Long> buyerIds = new HashSet<>();
for (LbOrderRow entity : entities) {
if (entity.getBuyerId() != null) {
buyerIds.add(entity.getBuyerId());
}
}
if (buyerIds.isEmpty()) {
return;
}
List<String> userIdStrs = new ArrayList<>(buyerIds.size());
for (Long buyerId : buyerIds) {
userIdStrs.add(String.valueOf(buyerId));
}
log.info("buyerIds:{}", userIdStrs.toString());
LambdaQueryWrapper<LbUser> w = new LambdaQueryWrapper<>();
w.eq(LbUser::getTenantId, tenantId)
.in(LbUser::getId, userIdStrs);
List<LbUser> users = lbUserService.list(w);
Map<String, LbUser> byUserId = new LinkedHashMap<>();
for (LbUser user : users) {
if (user.getId() != null && !byUserId.containsKey(user.getId())) {
byUserId.put(user.getId().toString(), user);
}
}
for (LbOrderRow entity : entities) {
if (entity.getBuyerId() == null) {
continue;
}
LbUser user = byUserId.get(String.valueOf(entity.getBuyerId()));
if (user != null) {
entity.setBuyerName(user.getNickname());
entity.setBuyerPhone(user.getMobile());
}
}
}
private static LbOrderRow toLbOrderRow(HxrOrderRow row, String tenantId) {
LbOrderRow e = new LbOrderRow();
@@ -699,6 +742,8 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
e.setSellerName(row.sellerName());
e.setSellerPhone(row.sellerPhone());
e.setBuyerId(row.buyerId());
e.setBuyerName(row.buyerName());
e.setBuyerPhone(row.buyerPhone());
e.setOrderSn(row.orderSn());
e.setTotalMoney(parseMoney(row.totalMoney()));
e.setPayTime(row.payTime());