按陆运线路叶子收窄工单和看板,避免中港权限看到全部陆运;产品/航线排名只留智能体团队。空运核对卡不再列出空的非必填,报价合计标明约数。中港口语里的车型吨位和按运费比例不再算进金额。报价单上传人显示机器人名,进后台拉标题不再误报没有权限。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+23
-3
@@ -51,11 +51,12 @@ public class InquiryBotReplyController extends JeecgController<InquiryBotReply,
|
||||
}
|
||||
|
||||
/**
|
||||
* 全量列表,供分类页一次加载。
|
||||
* 全量列表,供分类页一次加载;布局拉后台标题也会走到这里(旧前端缓存)。
|
||||
* 只要已登录即可读,不要求 inquiry:reply:list——中港等业务角色进看板否则会弹「没有权限」。
|
||||
* 增删改仍走带权限的 add/edit/enable/disable。
|
||||
* 必须显式大分页:Jeecg 分页拦截器可能把无 Page 的 list() 收成前 10 条,后台会看起来像没显示全。
|
||||
*/
|
||||
@ApiOperation("全量列表(按分类排序,供分类页一次加载)")
|
||||
@RequiresPermissions("inquiry:reply:list")
|
||||
@ApiOperation("全量列表(按分类排序,供分类页一次加载;登录可读)")
|
||||
@GetMapping("/listAll")
|
||||
public Result<List<InquiryBotReply>> listAll() {
|
||||
QueryWrapper<InquiryBotReply> qw = new QueryWrapper<>();
|
||||
@@ -66,6 +67,25 @@ public class InquiryBotReplyController extends JeecgController<InquiryBotReply,
|
||||
return Result.OK(botReplyService.page(page, qw).getRecords());
|
||||
}
|
||||
|
||||
/**
|
||||
* 读系统品牌文案(后台名称 / 机器人显示名)。
|
||||
* 只要已登录即可,不要求 inquiry:reply:list。
|
||||
* 中港等业务角色进看板会拉标题;若仍走 listAll 会弹「没有权限」。
|
||||
* 仅白名单 reply_code,禁止借此枚举全部回复语。
|
||||
*/
|
||||
@ApiOperation("系统品牌文案(登录可读,白名单码)")
|
||||
@GetMapping("/systemText")
|
||||
public Result<InquiryBotReply> systemText(@RequestParam(name = "replyCode") String replyCode) {
|
||||
String code = StringUtils.trimToEmpty(replyCode);
|
||||
if (!"system.admin_site_title".equals(code) && !"system.bot_display_name".equals(code)) {
|
||||
return Result.error("不支持的系统文案码");
|
||||
}
|
||||
InquiryBotReply row = botReplyService.getOne(new QueryWrapper<InquiryBotReply>()
|
||||
.eq("reply_code", code)
|
||||
.last("LIMIT 1"), false);
|
||||
return Result.OK(row);
|
||||
}
|
||||
|
||||
@AutoLog(value = "回复语-新增")
|
||||
@RequiresPermissions("inquiry:reply:add")
|
||||
@PostMapping("/add")
|
||||
|
||||
+5
@@ -15,6 +15,9 @@ import java.util.Date;
|
||||
|
||||
/**
|
||||
* 工单附件元数据,对应 inq_attachment。只存对象存储键,不存文件字节。
|
||||
* <p>
|
||||
* createBy:上传人(企微 userid / 登录名 / agent)。详情展示前会解析成姓名。
|
||||
* 为何:管理后台「附件记录·上传人」读此字段;实体缺字段则 API 永远不回上传人。
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@@ -33,6 +36,8 @@ public class InquiryAttachment implements Serializable {
|
||||
private String objectKey;
|
||||
private String contentType;
|
||||
private Long fileSize;
|
||||
/** 上传人:企微 userid、后台登录名或 agent;详情接口会解析成可读姓名。 */
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
||||
+156
-20
@@ -53,6 +53,8 @@ public class InquiryDashboardServiceImpl implements IInquiryDashboardService {
|
||||
|
||||
private static final ZoneId ZONE = ZoneId.of("Asia/Shanghai");
|
||||
private static final DateTimeFormatter DAY_FMT = DateTimeFormatter.ofPattern("MM-dd");
|
||||
/** 人员排名:销售 / 航线 / 产品 各自保留的条数(避免全局截断挤掉航线产品)。 */
|
||||
private static final int RANK_PER_ROLE = 20;
|
||||
private static final int COST_ROUTE_LIMIT = 16;
|
||||
/** 协同「分发」:海运/陆运建群、空运群激活。 */
|
||||
private static final List<String> COLLAB_DISPATCH_ACTIONS = Arrays.asList(
|
||||
@@ -168,7 +170,9 @@ public class InquiryDashboardServiceImpl implements IInquiryDashboardService {
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, Object>> rankings = buildRankings(tickets, staffByWecom, staffByName);
|
||||
// 产品/航线账号:人员排名只留智能体团队(航线+产品),不返回销售/用户
|
||||
boolean agentTeamOnly = isProductOrRouteViewer(staffByWecom);
|
||||
List<Map<String, Object>> rankings = buildRankings(tickets, staffByWecom, staffByName, agentTeamOnly);
|
||||
List<Map<String, Object>> costRoutes = buildCostRoutes(tickets, dayIndex, trendDates);
|
||||
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
@@ -178,11 +182,112 @@ public class InquiryDashboardServiceImpl implements IInquiryDashboardService {
|
||||
result.put("metrics", metricCards);
|
||||
result.put("trend", trend);
|
||||
result.put("rankings", rankings);
|
||||
// 前端据此隐藏「销售」筛选项;超管/销售账号为 all
|
||||
result.put("rankingScope", agentTeamOnly ? "agent_team" : "all");
|
||||
result.put("costDates", trendDates);
|
||||
result.put("costRoutes", costRoutes);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前登录人是否为产品/航线岗位(只能看智能体团队排名)。
|
||||
* <p>
|
||||
* 判定顺序:超管放行 → 员工表 wecom 岗位 air/sea/land → Jeecg 角色名含航线/产品/空运/海运/陆运。
|
||||
* 纯「销售」角色不算。无登录上下文时不收窄(避免内部调用被误锁)。
|
||||
*/
|
||||
private boolean isProductOrRouteViewer(Map<String, InquiryStaffRole> staffByWecom) {
|
||||
org.jeecg.common.system.vo.LoginUser login = currentLoginUser();
|
||||
if (login == null) {
|
||||
return false;
|
||||
}
|
||||
if (isDashboardAdministrator(login)) {
|
||||
return false;
|
||||
}
|
||||
String wecom = InquiryDataScopeSupport.wecomId(login);
|
||||
if (StringUtils.isNotBlank(wecom) && staffByWecom != null) {
|
||||
InquiryStaffRole staff = staffByWecom.get(wecom.trim());
|
||||
if (staff != null) {
|
||||
String code = StringUtils.trimToEmpty(staff.getRoleCode());
|
||||
if ("air".equals(code) || "sea".equals(code) || "land".equals(code)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
String username = StringUtils.trimToEmpty(login.getUsername());
|
||||
for (String roleName : loadSysRoleNames(username)) {
|
||||
if (roleNameLooksProductOrRoute(roleName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 角色名点明航线/产品(含空运/海运/陆运)。纯「销售」不含这些字,不算。 */
|
||||
static boolean roleNameLooksProductOrRoute(String roleName) {
|
||||
String name = StringUtils.trimToEmpty(roleName);
|
||||
if (name.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return name.contains("航线") || name.contains("产品")
|
||||
|| name.contains("空运") || name.contains("海运") || name.contains("陆运");
|
||||
}
|
||||
|
||||
private static org.jeecg.common.system.vo.LoginUser currentLoginUser() {
|
||||
try {
|
||||
Object p = org.apache.shiro.SecurityUtils.getSubject().getPrincipal();
|
||||
if (p instanceof org.jeecg.common.system.vo.LoginUser) {
|
||||
return (org.jeecg.common.system.vo.LoginUser) p;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// 无登录态
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isDashboardAdministrator(org.jeecg.common.system.vo.LoginUser login) {
|
||||
if (login == null) {
|
||||
return false;
|
||||
}
|
||||
if ("admin".equalsIgnoreCase(StringUtils.trimToEmpty(login.getUsername()))) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
return org.apache.shiro.SecurityUtils.getSubject().hasRole("admin")
|
||||
|| org.apache.shiro.SecurityUtils.getSubject().hasRole("管理员");
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 读账号绑定的 Jeecg 角色名;失败当无角色,不抛到看板。 */
|
||||
private static List<String> loadSysRoleNames(String username) {
|
||||
List<String> names = new ArrayList<>();
|
||||
if (StringUtils.isBlank(username)) {
|
||||
return names;
|
||||
}
|
||||
String sql = "SELECT r.role_name FROM sys_role r "
|
||||
+ "INNER JOIN sys_user_role ur ON ur.role_id = r.id "
|
||||
+ "INNER JOIN sys_user u ON u.id = ur.user_id WHERE u.username = ?";
|
||||
try {
|
||||
javax.sql.DataSource ds = org.jeecg.common.util.SpringContextUtils.getBean(javax.sql.DataSource.class);
|
||||
try (java.sql.Connection conn = ds.getConnection();
|
||||
java.sql.PreparedStatement ps = conn.prepareStatement(sql)) {
|
||||
ps.setString(1, username);
|
||||
try (java.sql.ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
String n = rs.getString("role_name");
|
||||
if (StringUtils.isNotBlank(n)) {
|
||||
names.add(n.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// 角色读失败不收窄
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析看板统计起止日。
|
||||
* 优先用显式 dateFrom/dateTo(与工单列表同源);否则按 range=today|7d|30d 相对「今天」。
|
||||
@@ -213,10 +318,13 @@ public class InquiryDashboardServiceImpl implements IInquiryDashboardService {
|
||||
/**
|
||||
* 人员排名:与工单列表 enrichDisplayFields 同口径。
|
||||
* 聚合键优先 salesWecomId(同人合并),展示名走 resolveSalesDisplayName。
|
||||
*
|
||||
* @param agentTeamOnly true 时只保留员工岗位为航线/产品的人(智能体团队),去掉销售与未绑定用户
|
||||
*/
|
||||
private static List<Map<String, Object>> buildRankings(List<InquiryTicket> tickets,
|
||||
Map<String, InquiryStaffRole> staffByWecom,
|
||||
Map<String, InquiryStaffRole> staffByName) {
|
||||
Map<String, InquiryStaffRole> staffByName,
|
||||
boolean agentTeamOnly) {
|
||||
class Acc {
|
||||
String name;
|
||||
InquiryStaffRole staff;
|
||||
@@ -260,24 +368,52 @@ public class InquiryDashboardServiceImpl implements IInquiryDashboardService {
|
||||
acc.name = acc.staff.getName().trim();
|
||||
}
|
||||
}
|
||||
return byKey.values().stream()
|
||||
.sorted(Comparator.comparingLong((Acc a) -> a.volume).reversed()
|
||||
.thenComparing(a -> a.name, Comparator.nullsLast(String::compareTo)))
|
||||
.limit(20)
|
||||
.map(a -> {
|
||||
Map<String, Object> row = new LinkedHashMap<>();
|
||||
row.put("name", a.name);
|
||||
if (a.staff != null) {
|
||||
row.put("role", mapRankRole(a.staff.getRoleCode()));
|
||||
row.put("dept", StringUtils.defaultIfBlank(a.staff.getDepartName(), "-"));
|
||||
} else {
|
||||
row.put("role", "sales");
|
||||
row.put("dept", "-");
|
||||
}
|
||||
row.put("volumeNum", a.volume);
|
||||
return row;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
// 按岗位分组各取 TopN,禁止全局 Top20 被销售占满导致「航线无人 / 产品只剩 1 人」
|
||||
Map<String, List<Acc>> grouped = new LinkedHashMap<>();
|
||||
grouped.put("sales", new ArrayList<>());
|
||||
grouped.put("route", new ArrayList<>());
|
||||
grouped.put("product", new ArrayList<>());
|
||||
for (Acc a : byKey.values()) {
|
||||
if (agentTeamOnly) {
|
||||
// 智能体团队:员工表航线(air)/产品(sea|land);销售与未绑定用户一律排除
|
||||
if (a.staff == null) {
|
||||
continue;
|
||||
}
|
||||
String rr = mapRankRole(a.staff.getRoleCode());
|
||||
if (!"route".equals(rr) && !"product".equals(rr)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
String role = a.staff != null ? mapRankRole(a.staff.getRoleCode()) : "sales";
|
||||
List<Acc> bucket = grouped.get(role);
|
||||
if (bucket == null) {
|
||||
bucket = grouped.get("sales");
|
||||
}
|
||||
bucket.add(a);
|
||||
}
|
||||
Comparator<Acc> byVolume = Comparator.comparingLong((Acc a) -> a.volume).reversed()
|
||||
.thenComparing(a -> a.name, Comparator.nullsLast(String::compareTo));
|
||||
List<Map<String, Object>> rows = new ArrayList<>();
|
||||
for (String roleKey : Arrays.asList("sales", "route", "product")) {
|
||||
List<Acc> bucket = grouped.get(roleKey);
|
||||
if (bucket == null || bucket.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
bucket.stream().sorted(byVolume).limit(RANK_PER_ROLE).forEach(a -> {
|
||||
Map<String, Object> row = new LinkedHashMap<>();
|
||||
row.put("name", a.name);
|
||||
if (a.staff != null) {
|
||||
row.put("role", mapRankRole(a.staff.getRoleCode()));
|
||||
row.put("dept", StringUtils.defaultIfBlank(a.staff.getDepartName(), "-"));
|
||||
} else {
|
||||
row.put("role", "sales");
|
||||
row.put("dept", "-");
|
||||
}
|
||||
row.put("volumeNum", a.volume);
|
||||
rows.add(row);
|
||||
});
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
@@ -954,6 +954,8 @@ public class InquiryQuoteTemplateServiceImpl extends ServiceImpl<InquiryQuoteTem
|
||||
row.setObjectKey(objectKey);
|
||||
row.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
row.setFileSize(fileSize);
|
||||
// 出单附件是智能体生成的,上传人固定 agent(详情展示成机器人显示名,禁止冒充发起人)。
|
||||
row.setCreateBy("agent");
|
||||
row.setCreateTime(new Date());
|
||||
attachmentMapper.insert(row);
|
||||
return true;
|
||||
|
||||
+131
-4
@@ -12,6 +12,7 @@ import org.jeecg.modules.inquiry.dto.AgentTicketCreateRequest;
|
||||
import org.jeecg.modules.inquiry.dto.TicketAbnormalRequest;
|
||||
import org.jeecg.modules.inquiry.dto.TicketTransitionRequest;
|
||||
import org.jeecg.modules.inquiry.entity.InquiryAttachment;
|
||||
import org.jeecg.modules.inquiry.entity.InquiryBotReply;
|
||||
import org.jeecg.modules.inquiry.entity.InquiryExceptionCase;
|
||||
import org.jeecg.modules.inquiry.entity.InquiryQuote;
|
||||
import org.jeecg.modules.inquiry.entity.InquiryStaffRole;
|
||||
@@ -46,10 +47,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -89,6 +86,13 @@ public class InquiryWorkOrderServiceImpl extends ServiceImpl<InquiryTicketMapper
|
||||
private InquiryExceptionNotifyMapper exceptionNotifyMapper;
|
||||
@Autowired
|
||||
private AgentSystemExceptionRetryClient exceptionRetryClient;
|
||||
@Autowired
|
||||
private org.jeecg.modules.inquiry.mapper.InquiryBotReplyMapper botReplyMapper;
|
||||
|
||||
/** 智能体出单/系统附件落库标记;详情展示时解析成机器人显示名。 */
|
||||
private static final String ATTACH_UPLOADER_AGENT = "agent";
|
||||
/** 与智能体 bot_name 默认一致;库里 system.bot_display_name 优先。 */
|
||||
private static final String DEFAULT_BOT_DISPLAY_NAME = "智价通AIQ";
|
||||
|
||||
@Override
|
||||
public IPage<InquiryTicket> pageView(Page<InquiryTicket> page, Map<String, String> filters) {
|
||||
@@ -228,6 +232,7 @@ public class InquiryWorkOrderServiceImpl extends ServiceImpl<InquiryTicketMapper
|
||||
List<InquiryAttachment> attachments = attachmentMapper.selectList(new LambdaQueryWrapper<InquiryAttachment>()
|
||||
.eq(InquiryAttachment::getWorkOrderNo, workOrderNo)
|
||||
.orderByAsc(InquiryAttachment::getCreateTime));
|
||||
enrichAttachmentUploaders(ticket, attachments);
|
||||
List<InquiryTicketStatusLog> timeline = statusLogMapper.selectList(new LambdaQueryWrapper<InquiryTicketStatusLog>()
|
||||
.eq(InquiryTicketStatusLog::getWorkOrderNo, workOrderNo)
|
||||
.orderByAsc(InquiryTicketStatusLog::getCreateTime));
|
||||
@@ -244,6 +249,126 @@ public class InquiryWorkOrderServiceImpl extends ServiceImpl<InquiryTicketMapper
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析附件上传人写入值。
|
||||
* <p>
|
||||
* 真人上传:用 body 的 senderId/createBy。
|
||||
* 智能体出单/系统落库:无真人 sender 时固定写 {@link #ATTACH_UPLOADER_AGENT},
|
||||
* <b>禁止</b>用发起人冒充上传人(产品:智价通AIQ 上传须显示智价通AIQ)。
|
||||
* 副作用:无;只读 body。
|
||||
*/
|
||||
private static String resolveAttachmentUploader(Map<String, Object> body, InquiryTicket ticket) {
|
||||
String fromBody = text(body, "createBy", "create_by", "senderId", "sender_id", "operatorUserId", "operator");
|
||||
if (StringUtils.isNotBlank(fromBody)) {
|
||||
String raw = fromBody.trim();
|
||||
// 显式 agent/system 保留;其它视为真人企微 id / 登录名。
|
||||
return raw;
|
||||
}
|
||||
return ATTACH_UPLOADER_AGENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情附件上传人展示:真人企微 id→姓名;agent/system/空→机器人显示名(智价通AIQ)。
|
||||
* 兼容错误回填:create_by 被写成发起人、但文件名是报价单时,仍按机器人显示。
|
||||
* 副作用:只改内存中的 createBy,不写库。
|
||||
*/
|
||||
private void enrichAttachmentUploaders(InquiryTicket ticket, List<InquiryAttachment> attachments) {
|
||||
if (attachments == null || attachments.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String botName = loadBotDisplayName();
|
||||
String salesWecom = ticket == null ? "" : StringUtils.trimToEmpty(ticket.getSalesWecomId());
|
||||
String salesName = ticket == null ? "" : StringUtils.trimToEmpty(ticket.getSalesName());
|
||||
Set<String> wecomIds = new HashSet<>();
|
||||
for (InquiryAttachment row : attachments) {
|
||||
if (row == null || StringUtils.isBlank(row.getCreateBy())) {
|
||||
continue;
|
||||
}
|
||||
String raw = row.getCreateBy().trim();
|
||||
if (isAgentUploaderMark(raw)) {
|
||||
continue;
|
||||
}
|
||||
wecomIds.add(raw);
|
||||
}
|
||||
Map<String, String> nameByWecom = Collections.emptyMap();
|
||||
if (!wecomIds.isEmpty()) {
|
||||
List<InquiryStaffRole> staffRows = staffRoleMapper.selectList(new LambdaQueryWrapper<InquiryStaffRole>()
|
||||
.in(InquiryStaffRole::getWecomId, new ArrayList<>(wecomIds))
|
||||
.eq(InquiryStaffRole::getStatus, "active"));
|
||||
nameByWecom = new HashMap<>();
|
||||
if (staffRows != null) {
|
||||
for (InquiryStaffRole staff : staffRows) {
|
||||
if (staff == null || StringUtils.isBlank(staff.getWecomId()) || StringUtils.isBlank(staff.getName())) {
|
||||
continue;
|
||||
}
|
||||
nameByWecom.put(staff.getWecomId().trim(), staff.getName().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (InquiryAttachment row : attachments) {
|
||||
if (row == null) {
|
||||
continue;
|
||||
}
|
||||
String raw = StringUtils.trimToEmpty(row.getCreateBy());
|
||||
String fileName = StringUtils.trimToEmpty(row.getFileName());
|
||||
boolean quoteSheet = looksLikeBotQuoteSheet(fileName);
|
||||
boolean mistookAsSales = StringUtils.isNotBlank(raw)
|
||||
&& (raw.equalsIgnoreCase(salesWecom) || raw.equals(salesName))
|
||||
&& quoteSheet;
|
||||
if (raw.isEmpty() || isAgentUploaderMark(raw) || mistookAsSales) {
|
||||
row.setCreateBy(botName);
|
||||
continue;
|
||||
}
|
||||
String named = nameByWecom.get(raw);
|
||||
if (StringUtils.isNotBlank(named)) {
|
||||
row.setCreateBy(named);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** agent/system 标记:智能体或系统落库,展示时换成机器人显示名。 */
|
||||
private static boolean isAgentUploaderMark(String raw) {
|
||||
return ATTACH_UPLOADER_AGENT.equalsIgnoreCase(raw) || "system".equalsIgnoreCase(raw);
|
||||
}
|
||||
|
||||
/** 文件名像智能体出的报价单(历史错误回填发起人时用来纠偏展示)。 */
|
||||
private static boolean looksLikeBotQuoteSheet(String fileName) {
|
||||
if (StringUtils.isBlank(fileName)) {
|
||||
return false;
|
||||
}
|
||||
String n = fileName.trim();
|
||||
return n.contains("报价单") || n.contains("报价表");
|
||||
}
|
||||
|
||||
/**
|
||||
* 读后台配置的机器人显示名(inq_bot_reply.system.bot_display_name)。
|
||||
* 空/停用回退 {@link #DEFAULT_BOT_DISPLAY_NAME}。
|
||||
*/
|
||||
private String loadBotDisplayName() {
|
||||
try {
|
||||
if (botReplyMapper == null) {
|
||||
return DEFAULT_BOT_DISPLAY_NAME;
|
||||
}
|
||||
InquiryBotReply row = botReplyMapper.selectOne(new LambdaQueryWrapper<InquiryBotReply>()
|
||||
.eq(InquiryBotReply::getReplyCode, "system.bot_display_name")
|
||||
.last("LIMIT 1"));
|
||||
if (row == null) {
|
||||
return DEFAULT_BOT_DISPLAY_NAME;
|
||||
}
|
||||
if (row.getEnabled() != null && row.getEnabled() == 0) {
|
||||
return DEFAULT_BOT_DISPLAY_NAME;
|
||||
}
|
||||
String text = StringUtils.trimToEmpty(row.getReplyText());
|
||||
if (text.isEmpty()) {
|
||||
return DEFAULT_BOT_DISPLAY_NAME;
|
||||
}
|
||||
String first = text.split("\\R", 2)[0].trim();
|
||||
return StringUtils.defaultIfBlank(first, DEFAULT_BOT_DISPLAY_NAME);
|
||||
} catch (Exception e) {
|
||||
return DEFAULT_BOT_DISPLAY_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表/详情响应补齐:发起人姓名、询价需求摘要、成本价/销售价/利润点、报价信息行。
|
||||
* 副作用:只改内存中的 ticket 展示字段,不 updateById。
|
||||
@@ -1441,6 +1566,7 @@ public class InquiryWorkOrderServiceImpl extends ServiceImpl<InquiryTicketMapper
|
||||
row.setFileName(text(body, "fileName", "file_name"));
|
||||
row.setObjectKey(text(body, "objectKey", "object_key"));
|
||||
row.setContentType(text(body, "contentType", "content_type"));
|
||||
row.setCreateBy(resolveAttachmentUploader(body, ticket));
|
||||
row.setCreateTime(new Date());
|
||||
attachmentMapper.insert(row);
|
||||
out.put("ok", true);
|
||||
@@ -1508,6 +1634,7 @@ public class InquiryWorkOrderServiceImpl extends ServiceImpl<InquiryTicketMapper
|
||||
row.setObjectKey(objectKey);
|
||||
row.setContentType(contentType);
|
||||
row.setFileSize((long) bytes.length);
|
||||
row.setCreateBy(resolveAttachmentUploader(body, ticket));
|
||||
row.setCreateTime(new Date());
|
||||
attachmentMapper.insert(row);
|
||||
out.put("ok", true);
|
||||
|
||||
+99
-7
@@ -16,7 +16,8 @@ import java.util.Set;
|
||||
* <p>
|
||||
* 只看自己:非超管且 {@code dashboardSelfOnly=true} →
|
||||
* {@code salesWecomId = 工号} 或 {@code createBy = 登录名}。
|
||||
* 业务范围:角色是陆运中港,或数据权限只有陆运线路时,看板和工单只留陆运。
|
||||
* 业务范围:先按空运/海运/陆运收窄;若 dataPerms 点了陆运线路叶子(如中港),
|
||||
* 再按 facts「线路类别」收窄,禁止中港权限看到东南亚等其它陆运单。
|
||||
* 看板与工单列表共用,避免只收一边。没有登录上下文时不限制(智能体内部调用)。
|
||||
* 线程:只读登录态,无全局锁。
|
||||
*/
|
||||
@@ -69,8 +70,9 @@ public final class InquiryDataScopeSupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* 按角色把工单收成空运 / 海运 / 陆运。不限制时原样返回。
|
||||
* 按角色把工单收成空运 / 海运 / 陆运,并在有陆运线路叶子时再按「线路类别」收窄。
|
||||
* 有业务线码时只认码;业务线空着才用中文标签兜底,避免海运单被写成「陆运」后漏出来。
|
||||
* 中港数据权限只勾「中港/中亚/中欧」时,不得再放出东南亚等其它陆运单。
|
||||
*/
|
||||
public static void applyRoleBizLines(LambdaQueryWrapper<InquiryTicket> qw) {
|
||||
if (qw == null) {
|
||||
@@ -117,25 +119,115 @@ public final class InquiryDataScopeSupport {
|
||||
}
|
||||
sql.append(" OR biz_type_label LIKE '%多段%' OR biz_type_label LIKE '%联运%'");
|
||||
sql.append(")))");
|
||||
|
||||
Set<String> landRoutes = InquiryQuoteTemplateBizScope.currentAllowedLandRoutesOrNull();
|
||||
String landRouteSql = buildLandRouteFilterSql(landRoutes);
|
||||
if (StringUtils.isNotBlank(landRouteSql)) {
|
||||
sql.insert(0, '(');
|
||||
sql.append(") AND (").append(landRouteSql).append(')');
|
||||
}
|
||||
qw.apply(sql.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 陆运线路叶子 SQL:只白名单目录码,禁止拼接用户原文。
|
||||
* 非陆运业务(AIR/SEA)放行;陆运/多段/空业务线必须 facts 线路类别命中。
|
||||
*
|
||||
* @return null 表示不追加线路条件
|
||||
*/
|
||||
static String buildLandRouteFilterSql(Set<String> landRoutes) {
|
||||
if (landRoutes == null) {
|
||||
return null;
|
||||
}
|
||||
List<String> safe = new ArrayList<String>();
|
||||
for (String raw : landRoutes) {
|
||||
String leaf = InquiryRoleBizScope.normalizeLandRouteKey(raw);
|
||||
if (leaf != null && !"陆运全线".equals(leaf)) {
|
||||
safe.add(leaf);
|
||||
}
|
||||
}
|
||||
StringBuilder landPred = new StringBuilder();
|
||||
if (safe.isEmpty()) {
|
||||
landPred.append("1 = 0");
|
||||
} else {
|
||||
landPred.append('(');
|
||||
for (int i = 0; i < safe.size(); i++) {
|
||||
if (i > 0) {
|
||||
landPred.append(" OR ");
|
||||
}
|
||||
String esc = safe.get(i).replace("'", "''");
|
||||
// MySQL 8:优先 JSON 抽取;再兼容无空格 / 有空格的手工 JSON
|
||||
landPred.append("(JSON_UNQUOTE(JSON_EXTRACT(facts_json, '$.\"线路类别\"')) = '")
|
||||
.append(esc).append("'")
|
||||
.append(" OR facts_json LIKE '%\"线路类别\":\"").append(esc).append("\"%'")
|
||||
.append(" OR facts_json LIKE '%\"线路类别\": \"").append(esc).append("\"%')");
|
||||
}
|
||||
landPred.append(')');
|
||||
}
|
||||
// 空运/海运业务线不受陆运线路叶子限制;陆运与多段必须命中线路。
|
||||
return "(UPPER(IFNULL(business_line,'')) IN ('AIR','SEA')"
|
||||
+ " OR (" + landPred + "))";
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情、流转、异常处理:列表里不该出现的工单,按编号打开也不给看。
|
||||
* 业务线通过后,若账号有陆运线路叶子,还要核对 facts 里的线路类别。
|
||||
*/
|
||||
public static void assertTicketBizAllowed(InquiryTicket ticket) {
|
||||
if (ticket == null) {
|
||||
return;
|
||||
}
|
||||
Set<String> allowed = InquiryQuoteTemplateBizScope.currentAllowedOrNull();
|
||||
if (InquiryRoleBizScope.ticketInScope(ticket.getBusinessLine(), ticket.getBizTypeLabel(), allowed)) {
|
||||
if (!InquiryRoleBizScope.ticketInScope(ticket.getBusinessLine(), ticket.getBizTypeLabel(), allowed)) {
|
||||
String scope = InquiryRoleBizScope.joinLabels(allowed);
|
||||
if (StringUtils.isBlank(scope)) {
|
||||
scope = "已授权业务";
|
||||
}
|
||||
throw new JeecgBootException("当前账号只能查看" + scope + "的询价工单和数据看板");
|
||||
}
|
||||
Set<String> landRoutes = InquiryQuoteTemplateBizScope.currentAllowedLandRoutesOrNull();
|
||||
if (landRoutes == null) {
|
||||
return;
|
||||
}
|
||||
String scope = InquiryRoleBizScope.joinLabels(allowed);
|
||||
if (StringUtils.isBlank(scope)) {
|
||||
scope = "已授权业务";
|
||||
String biz = InquiryRoleBizScope.classifyTicketBiz(ticket.getBusinessLine(), ticket.getBizTypeLabel());
|
||||
String line = StringUtils.trimToEmpty(ticket.getBusinessLine()).toUpperCase();
|
||||
String label = StringUtils.trimToEmpty(ticket.getBizTypeLabel());
|
||||
boolean landish = InquiryRoleBizScope.LAND.equals(biz)
|
||||
|| "MULTI".equals(line)
|
||||
|| label.contains("多段")
|
||||
|| label.contains("联运");
|
||||
// 纯空运/海运单:线路叶子不拦。
|
||||
if (!landish && (InquiryRoleBizScope.AIR.equals(biz) || InquiryRoleBizScope.SEA.equals(biz))) {
|
||||
return;
|
||||
}
|
||||
throw new JeecgBootException("当前账号只能查看" + scope + "的询价工单和数据看板");
|
||||
// 陆运权限账号打开陆运/多段单:必须线路类别命中;无线路类别宁可不看。
|
||||
if (landish || StringUtils.isBlank(biz)) {
|
||||
String route = extractRouteCategory(ticket.getFactsJson());
|
||||
if (InquiryRoleBizScope.ticketRouteInScope(route, landRoutes)) {
|
||||
return;
|
||||
}
|
||||
throw new JeecgBootException("当前账号只能查看已授权陆运线路的询价工单和数据看板");
|
||||
}
|
||||
}
|
||||
|
||||
/** 从 facts JSON 取线路类别;解析失败当空。 */
|
||||
static String extractRouteCategory(String factsJson) {
|
||||
if (StringUtils.isBlank(factsJson)) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
com.fasterxml.jackson.databind.JsonNode root =
|
||||
new com.fasterxml.jackson.databind.ObjectMapper().readTree(factsJson);
|
||||
for (String key : new String[]{"线路类别", "routeCategory", "landRouteCategory"}) {
|
||||
com.fasterxml.jackson.databind.JsonNode n = root.get(key);
|
||||
if (n != null && !n.isNull() && StringUtils.isNotBlank(n.asText())) {
|
||||
return n.asText().trim();
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// 解析失败当无线路
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+17
-1
@@ -40,7 +40,23 @@ public final class InquiryQuoteTemplateBizScope {
|
||||
}
|
||||
String username = StringUtils.trimToEmpty(login.getUsername());
|
||||
List<InquiryRoleBizScope.RoleSnap> roles = loadRoles(username);
|
||||
return InquiryRoleBizScope.resolve(isAdministrator(login, roles), roles);
|
||||
boolean admin = isAdministrator(login, roles);
|
||||
return InquiryRoleBizScope.resolve(admin, roles);
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前登录人允许的陆运线路叶子。
|
||||
*
|
||||
* @return {@code null} 表示不限制陆运线路;非空则工单/看板只留这些线路类别
|
||||
*/
|
||||
public static Set<String> currentAllowedLandRoutesOrNull() {
|
||||
LoginUser login = currentLoginUser();
|
||||
if (login == null) {
|
||||
return null;
|
||||
}
|
||||
String username = StringUtils.trimToEmpty(login.getUsername());
|
||||
List<InquiryRoleBizScope.RoleSnap> roles = loadRoles(username);
|
||||
return InquiryRoleBizScope.resolveLandRoutes(isAdministrator(login, roles), roles);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+108
-2
@@ -13,11 +13,13 @@ import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 把角色名称和角色数据权限,收成报价模板能用的业务线:空运 / 海运 / 陆运。
|
||||
* 把角色名称和角色数据权限,收成报价模板能用的业务线:空运 / 海运 / 陆运;
|
||||
* 以及工单/看板用的陆运线路叶子(中港 / 东南亚等)。
|
||||
* <p>
|
||||
* 数据权限写在 {@code sys_role.description} 的 {@code [dataPerms:…]},目录与后台
|
||||
* {@code dataPermCatalog.ts} 一致。报价模板只有业务线,没有「中港 / 国内整车」这一层,
|
||||
* 所以陆运线路(含中港)都归到「陆运」。
|
||||
* 所以陆运线路(含中港)在模板侧都归到「陆运」;工单与看板必须再按线路叶子收窄,
|
||||
* 否则「中港数据权限」会看到全部陆运工单。
|
||||
* <p>
|
||||
* 纯函数,不读库、不碰登录态。超管是否放行由调用方传入。
|
||||
*/
|
||||
@@ -121,6 +123,110 @@ public final class InquiryRoleBizScope {
|
||||
return allowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前账号允许的陆运线路叶子。
|
||||
* <p>
|
||||
* {@code null}:不限制陆运线路(超管、勾了「陆运全线」、或只有业务线「陆运」未点名具体线路)。
|
||||
* 非空:工单/看板只留这些线路类别(与 facts 里「线路类别」整词相同)。
|
||||
* 多个角色取并集;任一角色含「陆运全线」则整段不限制。
|
||||
* <p>
|
||||
* 与 {@link #resolve} 独立:角色名已点明「陆运」时 resolve 会跳过 dataPerms 的业务线并集,
|
||||
* 但线路叶子仍必须读 dataPerms,否则中港权限会漏成陆运全线。
|
||||
*/
|
||||
public static Set<String> resolveLandRoutes(boolean administrator, List<RoleSnap> roles) {
|
||||
if (administrator) {
|
||||
return null;
|
||||
}
|
||||
LinkedHashSet<String> routes = new LinkedHashSet<String>();
|
||||
boolean anyLandLeaf = false;
|
||||
boolean landAll = false;
|
||||
if (roles != null) {
|
||||
for (RoleSnap role : roles) {
|
||||
if (role == null) {
|
||||
continue;
|
||||
}
|
||||
for (String key : landRouteKeysOf(role)) {
|
||||
anyLandLeaf = true;
|
||||
if ("陆运全线".equals(key)) {
|
||||
landAll = true;
|
||||
} else {
|
||||
routes.add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (landAll) {
|
||||
return null;
|
||||
}
|
||||
if (!anyLandLeaf) {
|
||||
return null;
|
||||
}
|
||||
return routes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 一个角色描述 + 名称里点到的陆运线路叶子(含「陆运全线」)。
|
||||
* 只认目录稳定码;禁止把「中港/中亚/中欧」按斜杠切开。
|
||||
*/
|
||||
public static List<String> landRouteKeysOf(RoleSnap role) {
|
||||
LinkedHashSet<String> out = new LinkedHashSet<String>();
|
||||
if (role == null) {
|
||||
return new ArrayList<String>(out);
|
||||
}
|
||||
for (String key : parseDataPermKeys(role.getDescription())) {
|
||||
String leaf = normalizeLandRouteKey(key);
|
||||
if (leaf != null) {
|
||||
out.add(leaf);
|
||||
}
|
||||
}
|
||||
String name = StringUtils.trimToEmpty(role.getRoleName());
|
||||
if (!name.isEmpty()) {
|
||||
for (String known : LAND_ROUTE_KEYS) {
|
||||
if (name.contains(known)) {
|
||||
out.add(known);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ArrayList<String>(out);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据权限码 → 陆运线路叶子;非陆运叶子返回 null。
|
||||
*/
|
||||
public static String normalizeLandRouteKey(String raw) {
|
||||
String key = StringUtils.trimToEmpty(raw);
|
||||
if (key.isEmpty() || key.contains("系统异常")) {
|
||||
return null;
|
||||
}
|
||||
if (LAND_ROUTE_KEYS.contains(key)) {
|
||||
return key;
|
||||
}
|
||||
String leaf = key;
|
||||
int dot = Math.max(key.lastIndexOf('·'), key.lastIndexOf('•'));
|
||||
if (dot >= 0 && dot + 1 < key.length()) {
|
||||
leaf = key.substring(dot + 1).trim();
|
||||
}
|
||||
if (LAND_ROUTE_KEYS.contains(leaf)) {
|
||||
return leaf;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 工单线路类别是否在陆运线路权限内。{@code allowedLandRoutes == null} 不限制。
|
||||
* 空集合表示点了陆运叶子但解析结果为空,陆运单一律不可见。
|
||||
*/
|
||||
public static boolean ticketRouteInScope(String routeCategory, Set<String> allowedLandRoutes) {
|
||||
if (allowedLandRoutes == null) {
|
||||
return true;
|
||||
}
|
||||
String route = StringUtils.trimToEmpty(routeCategory);
|
||||
if (route.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return allowedLandRoutes.contains(route);
|
||||
}
|
||||
|
||||
/**
|
||||
* 界面下拉用的稳定顺序:空运、海运、陆运。{@code allowed == null} 时三项都返回。
|
||||
*/
|
||||
|
||||
+240
-6
@@ -806,7 +806,9 @@ public final class QuoteTemplateExcelSupport {
|
||||
// 禁止 Excel 重写 drawing(3983) 的 other_excel 包(WO013)。
|
||||
// 再盖回 WO011 sheet1 骨架,单选才稳定可见(WO030 vs POI 瘦 sheet)。
|
||||
syncSeaTransportClassFormControls(targetXlsx, facts, seaDrawParts);
|
||||
boolean scaffoldOk = restoreSeaSheet1Scaffold(targetXlsx, seaDrawParts);
|
||||
// 无费用明细时:骨架合并须清币别/单位/数量等样例,不能只清金额(WO202611050004)
|
||||
boolean wipeSeaFeeSamples = !hasSeaQuoteCharges(facts);
|
||||
boolean scaffoldOk = restoreSeaSheet1Scaffold(targetXlsx, seaDrawParts, null, wipeSeaFeeSamples);
|
||||
String seaCls = canonicalizeSeaTransportClass(facts == null ? null : firstNonBlank(
|
||||
facts.getString("运输分类"), facts.getString("transport_class"), facts.getString("sea_class")));
|
||||
if ("其他".equals(seaCls)) {
|
||||
@@ -1574,11 +1576,19 @@ public final class QuoteTemplateExcelSupport {
|
||||
* @return true=骨架盖回且合并成功;false=跳过/失败(调用方应写 B3 明文兜底)
|
||||
*/
|
||||
static boolean restoreSeaSheet1Scaffold(Path targetXlsx, Map<String, byte[]> preservedParts) {
|
||||
return restoreSeaSheet1Scaffold(targetXlsx, preservedParts, null);
|
||||
return restoreSeaSheet1Scaffold(targetXlsx, preservedParts, null, false);
|
||||
}
|
||||
|
||||
static boolean restoreSeaSheet1Scaffold(Path targetXlsx, Map<String, byte[]> preservedParts,
|
||||
String seaTransportClass) {
|
||||
return restoreSeaSheet1Scaffold(targetXlsx, preservedParts, seaTransportClass, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param wipeSeaFeeSamples true=无 TMS/人工费用时,清骨架费用行样例(含币别/单位/数量)
|
||||
*/
|
||||
static boolean restoreSeaSheet1Scaffold(Path targetXlsx, Map<String, byte[]> preservedParts,
|
||||
String seaTransportClass, boolean wipeSeaFeeSamples) {
|
||||
if (targetXlsx == null || !Files.isRegularFile(targetXlsx) || preservedParts == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -1611,7 +1621,7 @@ public final class QuoteTemplateExcelSupport {
|
||||
}
|
||||
Map<String, String> poiValues = parseSheetCellTexts(poiSheet, poiSst);
|
||||
byte[] scaffoldSst = loadWo011SeaSharedStrings();
|
||||
SeaSheetMerge merged = mergeValuesOntoSeaScaffold(scaffold, scaffoldSst, poiValues);
|
||||
SeaSheetMerge merged = mergeValuesOntoSeaScaffold(scaffold, scaffoldSst, poiValues, wipeSeaFeeSamples);
|
||||
int rowCount = countSheetRows(merged.sheetXml);
|
||||
// WO035 证据:错误正则把自闭合 <c .../> 的 / 吃进属性,一次匹配跨越多行,
|
||||
// sheet 从 17KB 缩成 7KB、只剩 2 行。合并结果过瘦则放弃,保留 POI 原 sheet。
|
||||
@@ -1787,13 +1797,22 @@ public final class QuoteTemplateExcelSupport {
|
||||
* sheetData 会从约 20KB 瘦到 17KB,WPS 界面可能不画顶部单选。
|
||||
* 策略:保留 WO011 原 SST 词序与索引,只追加新词;只改 POI 非空且与骨架不同的格;
|
||||
* B3:J3 单选锚点区一律不动。
|
||||
* <p>
|
||||
* 例外(WO202611050001):POI 已清空的费用样例格(40HQ/操作费/金额等)必须写成空格,
|
||||
* 禁止「空值不覆盖骨架」把 WO011 样例价盖回无 TMS 报价单。
|
||||
*/
|
||||
static SeaSheetMerge mergeValuesOntoSeaScaffold(byte[] scaffoldSheet, Map<String, String> poiValues) {
|
||||
return mergeValuesOntoSeaScaffold(scaffoldSheet, loadWo011SeaSharedStrings(), poiValues);
|
||||
return mergeValuesOntoSeaScaffold(scaffoldSheet, loadWo011SeaSharedStrings(), poiValues, false);
|
||||
}
|
||||
|
||||
static SeaSheetMerge mergeValuesOntoSeaScaffold(byte[] scaffoldSheet, byte[] scaffoldSst,
|
||||
Map<String, String> poiValues) {
|
||||
return mergeValuesOntoSeaScaffold(scaffoldSheet, scaffoldSst, poiValues, false);
|
||||
}
|
||||
|
||||
static SeaSheetMerge mergeValuesOntoSeaScaffold(byte[] scaffoldSheet, byte[] scaffoldSst,
|
||||
Map<String, String> poiValues,
|
||||
boolean wipeSeaFeeSamples) {
|
||||
String sheet = new String(scaffoldSheet, StandardCharsets.UTF_8);
|
||||
List<String> newSst = new ArrayList<>(parseSharedStrings(scaffoldSst));
|
||||
Map<String, Integer> sstIndex = new LinkedHashMap<>();
|
||||
@@ -1816,6 +1835,7 @@ public final class QuoteTemplateExcelSupport {
|
||||
|
||||
Map<String, String> scaffoldVals = parseSheetCellTexts(scaffoldSheet, scaffoldSst);
|
||||
|
||||
|
||||
java.util.regex.Matcher m = SEA_CELL_PATTERN.matcher(sheet);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
while (m.find()) {
|
||||
@@ -1834,19 +1854,70 @@ public final class QuoteTemplateExcelSupport {
|
||||
m.appendReplacement(sb, java.util.regex.Matcher.quoteReplacement(original));
|
||||
continue;
|
||||
}
|
||||
String scaffoldVal = scaffoldVals.get(ref);
|
||||
// 无价:清骨架费用行样例(金额/费目/币别/单位/数量/有效期)。
|
||||
// 但 POI 已写入且与骨架不同的业务值必须保留(WO202611050005:询价箱型 20GP*2
|
||||
// 不能因骨架曾是 40HQ*1 被一并清掉)。
|
||||
if (wipeSeaFeeSamples && isSeaScaffoldFeeSampleValue(scaffoldVal)) {
|
||||
String poiKeep = null;
|
||||
if (poiValues != null && poiValues.containsKey(ref)) {
|
||||
poiKeep = poiValues.get(ref);
|
||||
}
|
||||
if (poiKeep != null && !poiKeep.isEmpty()) {
|
||||
String keepNorm = poiKeep.replace("&", "&").replace("<", "<").replace(">", ">");
|
||||
String scNorm = scaffoldVal.replace("&", "&").replace("<", "<").replace(">", ">");
|
||||
if (!keepNorm.equals(scNorm)) {
|
||||
java.util.regex.Matcher smKeep = java.util.regex.Pattern.compile("\\bs=\"(\\d+)\"").matcher(attrs);
|
||||
String styleKeep = smKeep.find() ? (" s=\"" + smKeep.group(1) + "\"") : "";
|
||||
String keepRepl;
|
||||
if (keepNorm.matches("^-?\\d+(\\.\\d+)?$")) {
|
||||
keepRepl = "<c r=\"" + ref + "\"" + styleKeep + " t=\"n\"><v>" + keepNorm + "</v></c>";
|
||||
} else {
|
||||
int idxKeep = idxOf.apply(keepNorm);
|
||||
keepRepl = "<c r=\"" + ref + "\"" + styleKeep + " t=\"s\"><v>" + idxKeep + "</v></c>";
|
||||
}
|
||||
m.appendReplacement(sb, java.util.regex.Matcher.quoteReplacement(keepRepl));
|
||||
patched[0]++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
java.util.regex.Matcher smWipe = java.util.regex.Pattern.compile("\\bs=\"(\\d+)\"").matcher(attrs);
|
||||
String styleWipe = smWipe.find() ? (" s=\"" + smWipe.group(1) + "\"") : "";
|
||||
String emptyWipe = "<c r=\"" + ref + "\"" + styleWipe + "/>";
|
||||
m.appendReplacement(sb, java.util.regex.Matcher.quoteReplacement(emptyWipe));
|
||||
patched[0]++;
|
||||
continue;
|
||||
}
|
||||
if (poiValues == null || !poiValues.containsKey(ref)) {
|
||||
// POI 未带出该格:骨架费用样例仍要清,否则无价出单会冒出 40HQ 样例价
|
||||
if (isSeaScaffoldFeeSampleValue(scaffoldVal)) {
|
||||
java.util.regex.Matcher smMiss = java.util.regex.Pattern.compile("\\bs=\"(\\d+)\"").matcher(attrs);
|
||||
String styleMiss = smMiss.find() ? (" s=\"" + smMiss.group(1) + "\"") : "";
|
||||
String emptyMiss = "<c r=\"" + ref + "\"" + styleMiss + "/>";
|
||||
m.appendReplacement(sb, java.util.regex.Matcher.quoteReplacement(emptyMiss));
|
||||
patched[0]++;
|
||||
continue;
|
||||
}
|
||||
m.appendReplacement(sb, java.util.regex.Matcher.quoteReplacement(original));
|
||||
continue;
|
||||
}
|
||||
String val = poiValues.get(ref);
|
||||
if (val == null || val.isEmpty()) {
|
||||
// 费用样例:POI 已清空则必须写空,禁止盖回 WO011 样例(WO202611050001)
|
||||
if (isSeaScaffoldFeeSampleValue(scaffoldVal)) {
|
||||
java.util.regex.Matcher smEmpty = java.util.regex.Pattern.compile("\\bs=\"(\\d+)\"").matcher(attrs);
|
||||
String styleEmpty = smEmpty.find() ? (" s=\"" + smEmpty.group(1) + "\"") : "";
|
||||
String emptyRepl = "<c r=\"" + ref + "\"" + styleEmpty + "/>";
|
||||
m.appendReplacement(sb, java.util.regex.Matcher.quoteReplacement(emptyRepl));
|
||||
patched[0]++;
|
||||
continue;
|
||||
}
|
||||
// 空值不覆盖骨架(标签/样式格)
|
||||
m.appendReplacement(sb, java.util.regex.Matcher.quoteReplacement(original));
|
||||
continue;
|
||||
}
|
||||
// 去掉 POI/骨架可能带来的双重转义
|
||||
String norm = val.replace("&", "&").replace("<", "<").replace(">", ">");
|
||||
String scaffoldVal = scaffoldVals.get(ref);
|
||||
String scaffoldNorm = scaffoldVal == null ? ""
|
||||
: scaffoldVal.replace("&", "&").replace("<", "<").replace(">", ">");
|
||||
if (norm.equals(scaffoldNorm)) {
|
||||
@@ -1878,6 +1949,73 @@ public final class QuoteTemplateExcelSupport {
|
||||
return new SeaSheetMerge(sb.toString(), sstXml.toString(), newSst.size(), patched[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否有可写入报价单的海运费用(明细或总价)。无则出单须清骨架费用行样例。
|
||||
*/
|
||||
static boolean hasSeaQuoteCharges(JSONObject facts) {
|
||||
if (facts == null || facts.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
JSONArray charged = filterFeeRowsWithCharge(parseFeeRows(facts.get("fee_rows")));
|
||||
if (charged != null && !charged.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
String total = StringUtils.trimToEmpty(firstNonBlank(
|
||||
facts.getString("total_amount"), facts.getString("total"), facts.getString("salePrice")));
|
||||
return StringUtils.isNotBlank(total) && !"-".equals(total);
|
||||
}
|
||||
|
||||
/**
|
||||
* WO011 骨架里的费用行样例:箱型/费目/金额/币别/单位/数量;标题表头不算。
|
||||
* 用于无 TMS 报价时清掉样例,避免空值合并或 POI 残留把样例盖回出单表。
|
||||
*/
|
||||
static boolean isSeaScaffoldFeeSampleValue(String raw) {
|
||||
if (raw == null) {
|
||||
return false;
|
||||
}
|
||||
String s = raw.replace("&", "&").replace("<", "<").replace(">", ">").trim();
|
||||
if (s.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
// 费用表头「箱型(动态填充箱型)」/「箱型(20GP)」不是样例行,禁止当费用样例清掉
|
||||
if (s.contains("动态填充") || s.contains("动态箱型")
|
||||
|| (s.contains("箱型") && (s.contains("(") || s.contains("(") || s.contains("\n")))) {
|
||||
return false;
|
||||
}
|
||||
// 箱型样例:40HQ、20GP*1(数据行);勿把表头已填 20GP 当样例——上面已排除含「箱型」括号形
|
||||
if (s.matches("(?i)^\\d{2}(GP|HQ|OT|RF|TK|FR)(\\*\\d+)?$") || s.contains("40HQ") || s.contains("20GP")) {
|
||||
return true;
|
||||
}
|
||||
// 币别样例
|
||||
if ("CNY".equalsIgnoreCase(s) || "USD".equalsIgnoreCase(s) || "EUR".equalsIgnoreCase(s)
|
||||
|| "HKD".equalsIgnoreCase(s) || "RMB".equalsIgnoreCase(s)) {
|
||||
return true;
|
||||
}
|
||||
// 单位样例(费用行「柜/票/卡」;勿清表头「单位/Unit」)
|
||||
if ("柜".equals(s) || "票".equals(s) || "卡".equals(s) || "箱".equals(s)) {
|
||||
return true;
|
||||
}
|
||||
// 报价有效期等日期样例(询价日期若 POI 已写且不同则合并逻辑会保留)
|
||||
if (s.matches("^\\d{4}-\\d{2}-\\d{2}$")) {
|
||||
return true;
|
||||
}
|
||||
// 费用行数量/金额数字样例(含 1、0、1220.0)
|
||||
if (s.matches("^-?\\d+(\\.\\d+)?$")) {
|
||||
return true;
|
||||
}
|
||||
// 精确费目名(勿用「海运费用」标题;只认「海运费」等样例行)
|
||||
if ("操作费".equals(s) || "箱单费".equals(s) || "VGM申报费".equals(s) || "文件费".equals(s)
|
||||
|| "电放费".equals(s) || "更改费".equals(s) || "报关费".equals(s) || "海运费".equals(s)
|
||||
|| "进仓操作费".equals(s) || s.startsWith("封条费")
|
||||
|| s.startsWith("进口集装箱检验费") || s.startsWith("电子数据交换费")
|
||||
|| s.startsWith("进口设备监控费") || s.contains("CLTY") || s.contains("EDI")
|
||||
|| s.contains("EMCI")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static String xmlEscape(String s) {
|
||||
if (s == null) {
|
||||
return "";
|
||||
@@ -2308,7 +2446,11 @@ public final class QuoteTemplateExcelSupport {
|
||||
int stopRow = findStopRow(sheet, region.getJSONArray("stopAtText"), startRow);
|
||||
// 无明细:保留项目列骨架(空运段/起运港/目的港/其他),清掉样例费目名。
|
||||
// 对齐到港「有费用的才显示行」——到门模板样例(操作费/目的港派送费…)无报价时不得残留。
|
||||
// 但仍须替换表头「箱型(动态填充箱型)」→「箱型(20GP)」:无价不等于不要询价箱型(WO202611050009)。
|
||||
if (rows.isEmpty()) {
|
||||
if (Boolean.TRUE.equals(region.getBoolean("dynamicContainerHeader"))) {
|
||||
applyDynamicContainerHeader(sheet, region, columns, facts, yellow);
|
||||
}
|
||||
clearFeeRowsAfter(sheet, startRow, stopRow, columns, yellow, sheet.getSheetName(), true);
|
||||
continue;
|
||||
}
|
||||
@@ -3339,7 +3481,8 @@ public final class QuoteTemplateExcelSupport {
|
||||
yellow, sheet.getSheetName());
|
||||
}
|
||||
JSONObject vehicleRates = columns.getJSONObject("vehicleRates");
|
||||
if (vehicleRates != null) {
|
||||
int wroteRates = 0;
|
||||
if (vehicleRates != null && !vehicleRates.isEmpty()) {
|
||||
for (String vk : vehicleRates.keySet()) {
|
||||
String col = vehicleRates.getString(vk);
|
||||
if (StringUtils.isBlank(col)) {
|
||||
@@ -3348,14 +3491,99 @@ public final class QuoteTemplateExcelSupport {
|
||||
String price = resolveRouteVehicleRate(rowObj, facts, vk, vehicleRates.size(), kind);
|
||||
if (StringUtils.isNotBlank(price) && !"-".equals(price)) {
|
||||
writeFeeCol(sheet, ri, col, price, yellow, sheet.getSheetName());
|
||||
wroteRates++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 映射漏了 vehicleRates 时:按表头车型列扫写(与侧栏币种扫头同一思路)。
|
||||
// WO202610280104:境外段有起讫/CNY、车型运价全空,常见于仅映射了 origin/destination。
|
||||
wroteRates = writeLandMatrixVehicleRatesByHeaderScan(
|
||||
sheet, ri, region, rowObj, facts, yellow, kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 映射未给出 columns.vehicleRates 时,扫表头车型列再写运价。
|
||||
* <p>
|
||||
* 为何:千问 sheet_map 偶发只映射起始地/目的地/币种,漏掉整车矩阵车型列;
|
||||
* 侧栏币种已能扫头写入,车型列若不扫就会「有起讫无运价」。
|
||||
* 禁止:把同一售价灌进所有车型列(仍走 resolveRouteVehicleRate 匹配)。
|
||||
*
|
||||
* @return 实际写入的车型列数
|
||||
*/
|
||||
static int writeLandMatrixVehicleRatesByHeaderScan(Sheet sheet, int dataRow, JSONObject region,
|
||||
JSONObject rowObj, JSONObject facts,
|
||||
Set<String> yellow, String kind) {
|
||||
if (sheet == null || rowObj == null || region == null) {
|
||||
return 0;
|
||||
}
|
||||
int header0 = region.getIntValue("headerRow") - 1;
|
||||
if (header0 < 0) {
|
||||
header0 = dataRow - 1;
|
||||
}
|
||||
DataFormatter fmt = new DataFormatter();
|
||||
List<String> headers = new ArrayList<>();
|
||||
List<Integer> cols = new ArrayList<>();
|
||||
int from = Math.max(0, header0 - 1);
|
||||
int to = header0 + 1;
|
||||
for (int r = from; r <= to; r++) {
|
||||
Row row = sheet.getRow(r);
|
||||
if (row == null) {
|
||||
continue;
|
||||
}
|
||||
short last = row.getLastCellNum();
|
||||
for (int c = 0; c < last; c++) {
|
||||
String text = StringUtils.trimToEmpty(fmt.formatCellValue(row.getCell(c))).replaceAll("\\s+", "");
|
||||
if (!looksLikeLandMatrixVehicleHeader(text)) {
|
||||
continue;
|
||||
}
|
||||
if (cols.contains(c)) {
|
||||
continue;
|
||||
}
|
||||
headers.add(text);
|
||||
cols.add(c);
|
||||
}
|
||||
}
|
||||
if (headers.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
int wrote = 0;
|
||||
int headerCount = headers.size();
|
||||
for (int i = 0; i < headers.size(); i++) {
|
||||
String price = resolveRouteVehicleRate(rowObj, facts, headers.get(i), headerCount, kind);
|
||||
if (StringUtils.isBlank(price) || "-".equals(price)) {
|
||||
continue;
|
||||
}
|
||||
String col = CellReference.convertNumToColString(cols.get(i));
|
||||
writeFeeCol(sheet, dataRow, col, price, yellow, sheet.getSheetName());
|
||||
wrote++;
|
||||
}
|
||||
return wrote;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否陆运矩阵车型/柜型表头(3.5T、40HQ、13.75平板等),排除起始地/币种/时效。
|
||||
*/
|
||||
static boolean looksLikeLandMatrixVehicleHeader(String header) {
|
||||
if (StringUtils.isBlank(header)) {
|
||||
return false;
|
||||
}
|
||||
String t = header.trim();
|
||||
if (t.contains("起始") || t.contains("始发") || t.contains("目的") || t.contains("时效")
|
||||
|| t.contains("币种") || t.contains("币别") || t.contains("燃油") || t.contains("税率")
|
||||
|| t.contains("含税") || t.contains("备注") || "序号".equals(t)) {
|
||||
return false;
|
||||
}
|
||||
if (looksLikeVehicleTypeToken(t)) {
|
||||
return true;
|
||||
}
|
||||
String u = t.toUpperCase(Locale.ROOT);
|
||||
return t.contains("米/") || t.contains("尺") || u.matches(".*\\d+(\\.\\d+)?T.*")
|
||||
|| u.contains("HQ") || t.contains("平板") || t.contains("冷柜") || t.contains("厢车");
|
||||
}
|
||||
|
||||
/**
|
||||
* 运价表右侧时效、币种、燃油、税率、含税合计:按列头写到数据行。
|
||||
* 燃油/税率/含税合计只写行上或 TMS 已有的数,不编造。
|
||||
@@ -3883,6 +4111,12 @@ public final class QuoteTemplateExcelSupport {
|
||||
out.put("amount", sale);
|
||||
}
|
||||
}
|
||||
// 产品多车型价表:overseas_full / 分段切片后必须带上,否则境外段只剩起讫、车型列全空。
|
||||
JSONObject rates = vehicleRatesOf(row);
|
||||
if (rates != null && !rates.isEmpty()) {
|
||||
out.put("vehicleRates", rates);
|
||||
out.put("vehicle_rates", rates);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
-- 附件表补上传人 create_by,供管理后台「附件记录·上传人」展示。
|
||||
-- 仅改 inquiry_robot。列已存在则跳过(手工执行前请 DESCRIBE inq_attachment)。
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
ALTER TABLE `inq_attachment`
|
||||
ADD COLUMN `create_by` varchar(64) NULL COMMENT '上传人(企微userid/登录名/agent)' AFTER `file_size`;
|
||||
|
||||
-- 历史空上传人:智能体/系统附件写 agent(详情展示机器人显示名)。
|
||||
-- 禁止回填发起人:产品要求智价通AIQ 上传显示智价通AIQ,见 migration_inq_attachment_uploader_bot_v2.sql。
|
||||
UPDATE `inq_attachment`
|
||||
SET `create_by` = 'agent'
|
||||
WHERE `create_by` IS NULL OR TRIM(`create_by`) = '';
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
-- 纠正附件上传人:智能体报价单勿写成发起人,统一写 agent(详情展示机器人显示名)。
|
||||
-- 仅改 inquiry_robot。可重复执行。
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
UPDATE `inq_attachment` a
|
||||
INNER JOIN `inq_ticket` t ON t.work_order_no = a.work_order_no
|
||||
SET a.create_by = 'agent'
|
||||
WHERE (
|
||||
a.create_by = t.sales_name
|
||||
OR a.create_by = t.sales_wecom_id
|
||||
OR a.create_by IS NULL
|
||||
OR TRIM(a.create_by) = ''
|
||||
)
|
||||
AND (
|
||||
a.file_name LIKE '%报价单%'
|
||||
OR a.file_name LIKE '%报价表%'
|
||||
);
|
||||
+9
@@ -66,4 +66,13 @@ public class InquiryDashboardServiceImplTest {
|
||||
Assert.assertNull(InquiryDashboardServiceImpl.firstReplyAfter(
|
||||
java.util.Collections.singletonList(new java.util.Date(100L)), dispatch));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void roleNameLooksProductOrRouteDetectsOpsRoles() {
|
||||
Assert.assertTrue(InquiryDashboardServiceImpl.roleNameLooksProductOrRoute("海运产品"));
|
||||
Assert.assertTrue(InquiryDashboardServiceImpl.roleNameLooksProductOrRoute("空运航线"));
|
||||
Assert.assertTrue(InquiryDashboardServiceImpl.roleNameLooksProductOrRoute("陆运中港"));
|
||||
Assert.assertFalse(InquiryDashboardServiceImpl.roleNameLooksProductOrRoute("销售"));
|
||||
Assert.assertFalse(InquiryDashboardServiceImpl.roleNameLooksProductOrRoute(""));
|
||||
}
|
||||
}
|
||||
|
||||
+28
@@ -104,4 +104,32 @@ public class InquiryRoleBizScopeTest {
|
||||
assertEquals(InquiryRoleBizScope.LAND, InquiryRoleBizScope.classifyTicketBiz("land", ""));
|
||||
assertEquals("", InquiryRoleBizScope.classifyTicketBiz("MULTI", "陆运"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zhonggangDataPermResolvesOnlyZhonggangLandRoute() {
|
||||
Set<String> routes = InquiryRoleBizScope.resolveLandRoutes(false, Collections.singletonList(
|
||||
new InquiryRoleBizScope.RoleSnap("陆运产品:中港/中亚/中欧数据权限", "land_hk",
|
||||
"[dataPerms:中港/中亚/中欧]")));
|
||||
assertEquals(Collections.singleton("中港/中亚/中欧"), routes);
|
||||
assertTrue(InquiryRoleBizScope.ticketRouteInScope("中港/中亚/中欧", routes));
|
||||
assertFalse(InquiryRoleBizScope.ticketRouteInScope("东南亚", routes));
|
||||
assertFalse(InquiryRoleBizScope.ticketRouteInScope("", routes));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void landAllDataPermDoesNotRestrictLandRoutes() {
|
||||
assertNull(InquiryRoleBizScope.resolveLandRoutes(false, Collections.singletonList(
|
||||
new InquiryRoleBizScope.RoleSnap("陆运全线", "land_all",
|
||||
"[dataPerms:陆运全线]")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void landRouteFilterSqlOnlyWhitelistZhonggang() {
|
||||
String sql = InquiryDataScopeSupport.buildLandRouteFilterSql(
|
||||
Collections.singleton("中港/中亚/中欧"));
|
||||
assertTrue(sql.contains("中港/中亚/中欧"));
|
||||
assertTrue(sql.contains("facts_json"));
|
||||
assertTrue(sql.contains("AIR"));
|
||||
assertFalse(sql.contains("东南亚"));
|
||||
}
|
||||
}
|
||||
|
||||
+99
@@ -2423,6 +2423,105 @@ public class QuoteTemplateFillTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* overseas_full 切片必须带上 vehicleRates;否则多车型价只剩起讫,境外段运价全空(WO104 形态)。
|
||||
*/
|
||||
@Test
|
||||
public void sliceCrossBorderOdKeepsVehicleRatesMap() {
|
||||
JSONObject row = new JSONObject(true);
|
||||
row.put("origin", "大窑");
|
||||
row.put("destination", "越南某工业园");
|
||||
row.put("currency", "CNY");
|
||||
JSONObject rates = new JSONObject(true);
|
||||
rates.put("5T", "8000");
|
||||
rates.put("10T", "12000");
|
||||
row.put("vehicleRates", rates);
|
||||
JSONObject sliced = QuoteTemplateExcelSupport.sliceCrossBorderOd(row, "overseas_full");
|
||||
assertEquals("大窑", sliced.getString("origin"));
|
||||
assertEquals("CNY", sliced.getString("currency"));
|
||||
assertEquals("8000", QuoteTemplateExcelSupport.resolveRouteVehicleRate(
|
||||
sliced, null, "5T", 2, "overseas"));
|
||||
assertEquals("12000", QuoteTemplateExcelSupport.resolveRouteVehicleRate(
|
||||
sliced, null, "10T", 2, "overseas"));
|
||||
assertEquals("", QuoteTemplateExcelSupport.resolveRouteVehicleRate(
|
||||
sliced, null, "3.5T", 2, "overseas"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 映射漏掉 columns.vehicleRates 时,仍须按表头车型列写入运价(有起讫无运价的修复)。
|
||||
*/
|
||||
@Test
|
||||
public void landCrossBorderFtlHeaderScanWritesRateWhenMappingOmitsVehicleRates() throws Exception {
|
||||
Path src = Files.createTempFile("quote-land-cb-scan-src", ".xlsx");
|
||||
Path out = Files.createTempFile("quote-land-cb-scan-out", ".xlsx");
|
||||
try (Workbook wb = new XSSFWorkbook()) {
|
||||
Sheet sheet = wb.createSheet("跨境整车");
|
||||
row(sheet, 5).createCell(0).setCellValue("一、国内段报价");
|
||||
org.apache.poi.ss.usermodel.Row head1 = row(sheet, 7);
|
||||
head1.createCell(1).setCellValue("起始地");
|
||||
head1.createCell(2).setCellValue("目的地");
|
||||
head1.createCell(3).setCellValue("3T");
|
||||
head1.createCell(4).setCellValue("5T");
|
||||
row(sheet, 24).createCell(0).setCellValue("二、境外段报价");
|
||||
org.apache.poi.ss.usermodel.Row head2 = row(sheet, 26);
|
||||
head2.createCell(1).setCellValue("起始地");
|
||||
head2.createCell(2).setCellValue("目的地");
|
||||
head2.createCell(3).setCellValue("1.25T");
|
||||
head2.createCell(4).setCellValue("2.5T");
|
||||
head2.createCell(5).setCellValue("3.5T");
|
||||
head2.createCell(6).setCellValue("5T");
|
||||
head2.createCell(16).setCellValue("币种");
|
||||
try (java.io.OutputStream os = Files.newOutputStream(src)) {
|
||||
wb.write(os);
|
||||
}
|
||||
}
|
||||
JSONObject mapping = new JSONObject(true);
|
||||
mapping.put("sheet", "跨境整车");
|
||||
JSONArray regions = new JSONArray();
|
||||
JSONObject inland = new JSONObject(true);
|
||||
inland.put("title", "国内段报价");
|
||||
inland.put("headerRow", 8);
|
||||
inland.put("dataStartRow", 9);
|
||||
JSONObject cols1 = new JSONObject(true);
|
||||
cols1.put("origin", "B");
|
||||
cols1.put("destination", "C");
|
||||
// 故意不放 vehicleRates,复现映射漏列
|
||||
inland.put("columns", cols1);
|
||||
regions.add(inland);
|
||||
JSONObject overseas = new JSONObject(true);
|
||||
overseas.put("title", "境外段报价");
|
||||
overseas.put("headerRow", 27);
|
||||
overseas.put("dataStartRow", 28);
|
||||
JSONObject cols2 = new JSONObject(true);
|
||||
cols2.put("origin", "B");
|
||||
cols2.put("destination", "C");
|
||||
overseas.put("columns", cols2);
|
||||
regions.add(overseas);
|
||||
mapping.put("routeRegions", regions);
|
||||
JSONObject facts = new JSONObject(true);
|
||||
facts.put("运输类型", "跨境整车");
|
||||
facts.put("currency", "CNY");
|
||||
facts.put("route_rows",
|
||||
"[{\"origin\":\"大窑\",\"destination\":\"越南某工业园\","
|
||||
+ "\"vehicleType\":\"3T\",\"amount\":\"4500\",\"currency\":\"CNY\"}]");
|
||||
System.setProperty("ytd.agent.debug.runId", "wo104-header-scan");
|
||||
QuoteTemplateExcelSupport.fillWorkbook(src, out, mapping, facts);
|
||||
try (Workbook filled = new XSSFWorkbook(Files.newInputStream(out))) {
|
||||
Sheet sheet = filled.getSheetAt(0);
|
||||
assertEquals("", read(sheet, 8, 1));
|
||||
assertEquals("大窑", read(sheet, 27, 1));
|
||||
assertEquals("越南某工业园", read(sheet, 27, 2));
|
||||
assertEquals("CNY", read(sheet, 27, 16));
|
||||
// 3T → 境外 3.5T 列(F,index 5)
|
||||
assertEquals("4500", normalizeMoney(read(sheet, 27, 5)));
|
||||
assertEquals("", read(sheet, 27, 3));
|
||||
assertEquals("", read(sheet, 27, 6));
|
||||
} finally {
|
||||
Files.deleteIfExists(src);
|
||||
Files.deleteIfExists(out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 境外段「起始地」若是白底,对齐表头时不能拿它去刷「币种」灰底。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user