demand: 漏组批次、供应商线路规划相关需求代码重构。供应商线路规划新增导入接口

committer: heyu
This commit is contained in:
aike 2025-05-15 14:29:01 +08:00
parent 2820973355
commit c5dee14a0f
15 changed files with 519 additions and 696 deletions

View File

@ -2,6 +2,7 @@ package com.xdadan.erp.web.emis;
import java.util.List;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.xdadan.erp.common.annotation.filter.jackson.JacksonFilter;
import com.xdadan.erp.common.core.domain.AjaxResult;
import com.xdadan.erp.common.core.page.TableDataInfo;
@ -71,6 +72,15 @@ public class EmisTransPlanRuleController extends EmisBaseController {
return toAjax(emisTransPlanRuleService.insertEmisTransPlanRule(emisTransPlanRule));
}
/**
* Excel草稿方式新增
*/
@PreAuthorize("@ss.hasPermi('emis:emisTransPlanRule:draftSubmitRule')")
@PostMapping(value = "/draftSubmitRule")
public AjaxResult draftSubmitRule(@RequestBody EmisTransPlanRule emisTransPlanRule) throws EmisBizError {
return toAjax(emisTransPlanRuleService.draftSubmitRule(emisTransPlanRule));
}
/**
* 修改供应商线路规划
*/
@ -94,7 +104,7 @@ public class EmisTransPlanRuleController extends EmisBaseController {
*/
@PreAuthorize("@ss.hasPermi('emis:emisTransPlanRule:tree')")
@GetMapping("/tree")
public TableDataInfo tree(String lineCode) {
return getDataTable(emisTransPlanRuleService.selectEmisTransPlanRuleTree(lineCode));
public TableDataInfo tree(EmisTransPlanRule emisTransPlanRule) {
return getDataTable(emisTransPlanRuleService.selectEmisTransPlanRuleTree(emisTransPlanRule));
}
}

View File

@ -27,8 +27,10 @@ public class EmisTmsSiteBatchMiss extends BaseEntity {
private Long transPlanRuleId;
/* 运单号 */
private String billCode;
/* 线路负责人 */
/* 节点负责人 */
private String manager;
/* 线路负责人 */
private String transManager;
/* 寄件网点编码 */
private String sendSiteCode;
/* 寄件网点名称 */

View File

@ -76,4 +76,6 @@ public class EmisTransLine extends BaseEntity
private String countryName;
private String logoTypeName;
/* 线路负责人 */
private String transManager;
}

View File

@ -1,9 +1,16 @@
package com.xdadan.erp.emis.domain;
import java.util.Date;
import java.util.List;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xdadan.erp.common.core.domain.BaseEntity;
import lombok.Data;
import com.xdadan.erp.common.annotation.Excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.converters.date.DateStringConverter;
import com.alibaba.excel.converters.longconverter.LongNumberConverter;
/**
* 供应商线路规划表对象 emis_trans_plan_rule
@ -30,16 +37,17 @@ public class EmisTransPlanRule extends BaseEntity {
/** 线路名称 (仅用于查询结果) */
private String lineName;
/** 运输方式 */
private String transType;
/** 产品类型 */
private String productType;
/** 产品类型名称 */
/**
* 产品类型名称
*/
private String productTypeName;
/** 起始网点编码 */
/**
* 起始网点编码
*/
private String startSiteCode;
/** 下一网点编码 */
@ -51,7 +59,7 @@ public class EmisTransPlanRule extends BaseEntity {
/** 下一网点名称 */
private String nextSiteName;
/** 线路负责人 */
/** 节点负责人 */
private String manager;
/** 供应商编码 */
@ -60,8 +68,13 @@ public class EmisTransPlanRule extends BaseEntity {
/** 供应商名称 */
private String supplierName;
/** 状态 1-启用 0-不启用 */
private String status;
/** 生效时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date startDate;
/** 失效时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date endDate;
/** 子节点 */
private List<EmisTransPlanRule> children;

View File

@ -25,6 +25,7 @@ public enum EmisBizErrorType {
SUCCESS("0000", "成功"),
FAIL("9999", "失败"),
PARAM_ERROR("E005", "参数错误"),
PARAM_ERROR1("E001", "参数不完整"),
CALC_FEE_ERROR("E002", "运费计算错误"),
CALC_WEIGHT_ERROR("E003", "重量计算错误"),

View File

@ -21,7 +21,7 @@ public interface EmisTransPlanRuleMapper {
public EmisTransPlanRule selectEmisTransPlanRuleById(Long id);
/**
* 查询供应商线路规划列表,过滤根节点
* 查询供应商线路规划列表
*
* @param emisTransPlanRule 供应商线路规划
* @return 供应商线路规划集合
@ -29,28 +29,12 @@ public interface EmisTransPlanRuleMapper {
public List<EmisTransPlanRule> selectEmisTransPlanRuleList(EmisTransPlanRule emisTransPlanRule);
/**
* 查询供应商线路规划列表,查询包括根节点
* 查询供应商线路规划列表
*
* @param emisTransPlanRule 供应商线路规划
* @return 供应商线路规划集合
*/
public List<EmisTransPlanRule> getEmisTransPlanRuleList(EmisTransPlanRule emisTransPlanRule);
/**
* 查询子节点列表
*
* @param id 父节点ID
* @return 子节点列表
*/
public List<EmisTransPlanRule> selectChildrenEmisTransPlanRuleById(Long id);
/**
* 查询是否存在子节点
*
* @param id 节点ID
* @return 结果
*/
public int hasChildByEmisTransPlanRuleId(Long id);
public List<EmisTransPlanRule> checkDuplicate(EmisTransPlanRule emisTransPlanRule);
/**
* 新增供应商线路规划
@ -68,14 +52,6 @@ public interface EmisTransPlanRuleMapper {
*/
public int updateEmisTransPlanRule(EmisTransPlanRule emisTransPlanRule);
/**
* 删除供应商线路规划
*
* @param id 供应商线路规划主键
* @return 结果
*/
public int deleteEmisTransPlanRuleById(Long id);
/**
* 批量删除供应商线路规划
*
@ -123,4 +99,36 @@ public interface EmisTransPlanRuleMapper {
* @return 运输计划规则列表
*/
List<EmisTransPlanRule> selectTransPlanRuleByLineCode(@Param("lineCode") String lineCode);
/**
* 根据产品类型名称查询产品类型信息
*
* @param productTypeNames 产品类型名称列表
* @return 产品类型信息列表
*/
public List<Map<String, String>> selectProductTypeInfoByNames(List<String> productTypeNames);
/**
* 根据网点名称查询网点信息
*
* @param siteNames 网点名称列表
* @return 网点信息列表
*/
public List<Map<String, String>> selectSiteInfoByNames(List<String> siteNames);
/**
* 根据供应商名称查询供应商信息
*
* @param supplierNames 供应商名称列表
* @return 供应商信息列表
*/
public List<Map<String, String>> selectSupplierInfoByNames(List<String> supplierNames);
/**
* 根据线路名称查询线路信息
*
* @param lineNames 线路名称列表
* @return 线路信息列表
*/
public List<Map<String, String>> selectLineInfoByNames(List<String> lineNames);
}

View File

@ -37,6 +37,7 @@ package com.xdadan.erp.emis.service;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.WordUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -3855,6 +3856,145 @@ public class EmisBaseService {
return weekDays;
}
public List<EmisTransPlanRule> buildTree(List<EmisTransPlanRule> allRules) {
// 按lineCode分组
Map<String, List<EmisTransPlanRule>> groupByLine = allRules.stream()
.collect(Collectors.groupingBy(EmisTransPlanRule::getLineCode));
List<EmisTransPlanRule> result = new ArrayList<>();
// 处理每个lineCode分组
for (Map.Entry<String, List<EmisTransPlanRule>> lineEntry : groupByLine.entrySet()) {
List<EmisTransPlanRule> lineRules = lineEntry.getValue();
if (lineRules.isEmpty()) {
continue;
}
// 按productType分组
Map<String, List<EmisTransPlanRule>> groupByProductType = lineRules.stream()
.collect(Collectors.groupingBy(EmisTransPlanRule::getProductType));
// 处理每个productType分组
for (Map.Entry<String, List<EmisTransPlanRule>> productEntry : groupByProductType.entrySet()) {
List<EmisTransPlanRule> productRules = productEntry.getValue();
// 构建站点关系树
Map<String, List<EmisTransPlanRule>> nodeMap = new HashMap<>();
for (EmisTransPlanRule rule : productRules) {
String key = rule.getNextSiteCode() != null ? rule.getNextSiteCode() : rule.getStartSiteCode();
if (key != null) {
nodeMap.computeIfAbsent(key, k -> new ArrayList<>()).add(rule);
}
}
// 按startSiteCode分组,找出所有可能的父节点
Map<String, List<EmisTransPlanRule>> parentGroups = productRules.stream()
.filter(rule -> rule.getStartSiteCode() != null)
.collect(Collectors.groupingBy(EmisTransPlanRule::getStartSiteCode));
// 设置父子关系
for (Map.Entry<String, List<EmisTransPlanRule>> parentGroup : parentGroups.entrySet()) {
String startSiteCode = parentGroup.getKey();
List<EmisTransPlanRule> children = parentGroup.getValue();
// 获取所有可能的父节点
List<EmisTransPlanRule> parents = nodeMap.get(startSiteCode);
if (parents != null) {
for (EmisTransPlanRule parent : parents) {
if (parent.getChildren() == null) {
parent.setChildren(new ArrayList<>());
}
// 添加所有子节点到父节点的children列表中
for (EmisTransPlanRule child : children) {
if (!parent.getChildren().contains(child)) {
parent.getChildren().add(child);
}
}
}
}
}
// 找出顶级节点(没有父节点的节点)
List<EmisTransPlanRule> topLevelNodes = productRules.stream()
.filter(rule -> {
// 检查该节点是否作为其他节点的子节点
boolean isChild = productRules.stream()
.anyMatch(potential -> potential.getChildren() != null
&& potential.getChildren().contains(rule));
return !isChild;
})
.collect(Collectors.toList());
// 将顶级节点直接添加到结果中(进行深度复制)
for (EmisTransPlanRule node : topLevelNodes) {
result.add(deepCopyNode(node));
}
}
}
// 递归设置父ID和祖先节点ID
for (EmisTransPlanRule root : result) {
setParentAndAncestors(root, null, "");
}
return result;
}
/**
* 递归设置父ID和祖先节点ID
*
* @param node 当前节点
* @param parentId 父节点ID
* @param ancestors 祖先节点ID字符串
*/
private void setParentAndAncestors(EmisTransPlanRule node, Long parentId, String ancestors) {
if (node == null) {
return;
}
// 设置父ID
node.setParentId(parentId);
// 设置祖先节点ID
node.setAncestors(ancestors);
// 处理子节点,子节点的祖先包含当前节点和当前节点的所有祖先
if (node.getChildren() != null && !node.getChildren().isEmpty()) {
String childAncestors = ancestors.isEmpty() ? node.getId().toString() : ancestors + "," + node.getId();
for (EmisTransPlanRule child : node.getChildren()) {
setParentAndAncestors(child, node.getId(), childAncestors);
}
}
}
/**
* 深度复制节点及其子节点
*
* @param source 源节点
* @return 复制后的新节点
*/
private EmisTransPlanRule deepCopyNode(EmisTransPlanRule source) {
if (source == null) {
return null;
}
EmisTransPlanRule copy = new EmisTransPlanRule();
BeanUtils.copyProperties(source, copy);
// 递归复制子节点
if (source.getChildren() != null) {
List<EmisTransPlanRule> copiedChildren = new ArrayList<>();
for (EmisTransPlanRule child : source.getChildren()) {
copiedChildren.add(deepCopyNode(child));
}
copy.setChildren(copiedChildren);
}
return copy;
}
public static void main(String[] args) {
// Date startDate = new Date();
// Date endDate = DateUtils.addDays(startDate, 10);

View File

@ -51,21 +51,13 @@ public interface IEmisTransPlanRuleService {
*/
public int deleteEmisTransPlanRuleByIds(Long[] ids) throws EmisBizError;
/**
* 删除供应商线路规划信息
*
* @param id 供应商线路规划主键
* @return 结果
*/
public int deleteEmisTransPlanRuleById(Long id);
/**
* 查询供应商线路规划树结构
*
* @param lineCode 线路编码
* @param emisTransPlanRule 查询条件
* @return 供应商线路规划树结构
*/
public List<EmisTransPlanRule> selectEmisTransPlanRuleTree(String lineCode);
public List<EmisTransPlanRule> selectEmisTransPlanRuleTree(EmisTransPlanRule emisTransPlanRule);
/**
* 根据条件查询供应商信息
@ -74,4 +66,12 @@ public interface IEmisTransPlanRuleService {
* @return 供应商信息列表
*/
List<EmisTransPlanRule> selectSupplierInfoByConditions(EmisTransPlanRule emisTransPlanRule);
/**
* Excel草稿方式新增
*
* @param emisTransPlanRule 供应商线路规划
* @return 结果
*/
int draftSubmitRule(EmisTransPlanRule emisTransPlanRule) throws EmisBizError;
}

View File

@ -8,19 +8,15 @@ import java.util.concurrent.Executors;
import cn.hutool.core.collection.CollectionUtil;
import com.beust.jcommander.internal.Lists;
import com.xdadan.erp.common.utils.SecurityUtils;
import com.xdadan.erp.emis.domain.*;
import com.xdadan.erp.emis.mapper.*;
import com.xdadan.erp.emis.service.EmisBaseService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xdadan.erp.emis.service.IEmisTmsSiteBatchMissService;
import static com.xdadan.erp.common.utils.SecurityUtils.getLoginUser;
/**
* TMS漏组批次信息Service业务层处理
*
@ -28,7 +24,7 @@ import static com.xdadan.erp.common.utils.SecurityUtils.getLoginUser;
*/
@Service
@Slf4j
public class EmisTmsSiteBatchMissServiceImpl implements IEmisTmsSiteBatchMissService {
public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements IEmisTmsSiteBatchMissService {
@Autowired
private EmisTmsSiteBatchMissMapper emisTmsSiteBatchMissMapper;
@ -143,10 +139,8 @@ public class EmisTmsSiteBatchMissServiceImpl implements IEmisTmsSiteBatchMissSer
}
// 按线路编码分组
Map<String, EmisTransPlanRule> transPlanRulesByLineCode = new HashMap<>();
treeRules.stream().filter(Objects::nonNull).forEach(i -> {
transPlanRulesByLineCode.put(i.getLineCode(), i);
});
Map<String, List<EmisTransPlanRule>> transPlanRulesByLineCode = treeRules.stream()
.collect(Collectors.groupingBy(EmisTransPlanRule::getLineCode));
// 创建线程池
int processors = Runtime.getRuntime().availableProcessors();
@ -278,7 +272,7 @@ public class EmisTmsSiteBatchMissServiceImpl implements IEmisTmsSiteBatchMissSer
}
private ProcessResult processWaybillBatch(List<EmisWaybill> waybills,
Map<String, EmisTransPlanRule> transPlanRulesByLineCode) {
Map<String, List<EmisTransPlanRule>> transPlanRulesByLineCode) {
int successCount = 0;
int failCount = 0;
List<String> failedBillCodes = new ArrayList<>();
@ -307,8 +301,8 @@ public class EmisTmsSiteBatchMissServiceImpl implements IEmisTmsSiteBatchMissSer
for (EmisWaybill waybill : waybills) {
try {
// 获取运单对应的线路规划
EmisTransPlanRule emisTransPlanRule = transPlanRulesByLineCode.get(waybill.getTransLineType());
if (Objects.isNull(emisTransPlanRule)) {
List<EmisTransPlanRule> ruleListByTransLineType = transPlanRulesByLineCode.get(waybill.getTransLineType());
if (CollectionUtil.isEmpty(ruleListByTransLineType)) {
// 创建漏组记录
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
miss.setMissReason("当前线路没有创建对应的线路规划");
@ -317,13 +311,29 @@ public class EmisTmsSiteBatchMissServiceImpl implements IEmisTmsSiteBatchMissSer
continue;
}
List<EmisTransPlanRule> ruleListByProductType = ruleListByTransLineType.stream()
.filter(i -> StringUtils.isNotBlank(i.getProductType())
&& i.getProductType().contains(waybill.getProductType()))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(ruleListByProductType)) {
// 创建漏组记录
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
miss.setMissReason("当前线路没有创建对应的产品类型");
missRecords.add(miss);
successCount++;
continue;
}
// 获取运单对应的组批次信息
List<EmisTmsSiteBatch> waybillBatches = siteBatchesByBillCode.get(waybill.getBillCode());
if (CollectionUtil.isEmpty(waybillBatches)) {
// 创建漏组记录
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
miss.setMissReason("当前运单没有组批次");
miss.setTransPlanRuleId(emisTransPlanRule.getId());
// miss.setTransPlanRuleId(ruleListByTransLineType.stream()
// .sorted(Comparator.comparing(EmisTransPlanRule::getId))
// .collect(Collectors.toList()).get(0).getId());
missRecords.add(miss);
successCount++;
continue;
@ -347,7 +357,7 @@ public class EmisTmsSiteBatchMissServiceImpl implements IEmisTmsSiteBatchMissSer
waybillBatches = new ArrayList<>(mergedBatches.values());
// 检查运单是否匹配线路规划树
boolean isAnyBranchMatched = checkBranchMatch(emisTransPlanRule, waybillBatches, waybill,
boolean isAnyBranchMatched = checkBranchMatch(ruleListByProductType, waybillBatches, waybill,
missRecords);
if (isAnyBranchMatched) {
@ -373,206 +383,12 @@ public class EmisTmsSiteBatchMissServiceImpl implements IEmisTmsSiteBatchMissSer
public List<EmisTransPlanRule> selectEmisTransPlanRuleTree() {
log.info("Start querying supplier route plan tree");
List<EmisTransPlanRule> list = emisTransPlanRuleMapper.getEmisTransPlanRuleList(new EmisTransPlanRule());
setName(list);
List<EmisTransPlanRule> list = emisTransPlanRuleMapper.selectEmisTransPlanRuleList(new EmisTransPlanRule());
List<EmisTransPlanRule> tree = buildTree(list);
log.info("Queried supplier route plan tree, node count={}", tree != null ? tree.size() : 0);
return tree;
}
private void setName(List<EmisTransPlanRule> list) {
setSupplierNames(list);
setProductTypeNames(list);
setLineName(list);
}
/**
* 设置供应商名称
*/
private void setSupplierNames(List<EmisTransPlanRule> rules) {
if (rules == null || rules.isEmpty()) {
log.info("Setting supplier names: rules list is empty");
return;
}
// 收集所有需要查询的供应商编码
List<String> supplierCodes = rules.stream()
.map(EmisTransPlanRule::getSupplierCode)
.filter(org.springframework.util.StringUtils::hasText)
.flatMap(code -> Arrays.stream(code.split(",")))
.distinct()
.collect(Collectors.toList());
log.info("Setting supplier names: code count={}, codes={}", supplierCodes.size(), supplierCodes);
if (!supplierCodes.isEmpty()) {
// 批量查询供应商信息
List<Map<String, String>> supplierInfos = emisTransPlanRuleMapper.selectSupplierInfoByCodes(supplierCodes);
log.info("Setting supplier names: found supplier info count={}",
supplierInfos != null ? supplierInfos.size() : 0);
if (supplierInfos != null && !supplierInfos.isEmpty()) {
// 创建供应商编码到名称的映射
Map<String, String> supplierCodeToNameMap = supplierInfos.stream()
.collect(Collectors.toMap(
info -> info.get("code"),
info -> info.get("name"),
(existing, replacement) -> existing));
log.info("Setting supplier names: code to name mapping count={}", supplierCodeToNameMap.size());
// 设置供应商名称
rules.forEach(rule -> {
if (org.springframework.util.StringUtils.hasText(rule.getSupplierCode())) {
String names = Arrays.stream(rule.getSupplierCode().split(","))
.map(code -> supplierCodeToNameMap.getOrDefault(code, ""))
.filter(org.springframework.util.StringUtils::hasText)
.collect(Collectors.joining(","));
rule.setSupplierName(names);
log.debug("Setting supplier name: id={}, supplierCode={}, supplierName={}",
rule.getId(), rule.getSupplierCode(), names);
}
});
}
}
}
/**
* 设置产品类型名称
*/
private void setProductTypeNames(List<EmisTransPlanRule> rules) {
if (rules == null || rules.isEmpty()) {
log.info("Setting product type names: rules list is empty");
return;
}
// 收集所有需要查询的产品类型编码
List<String> productTypes = rules.stream()
.map(EmisTransPlanRule::getProductType)
.filter(org.springframework.util.StringUtils::hasText)
.flatMap(type -> Arrays.stream(type.split(",")))
.distinct()
.collect(Collectors.toList());
log.info("Setting product type names: code count={}, codes={}", productTypes.size(), productTypes);
if (!productTypes.isEmpty()) {
// 批量查询产品类型信息
List<Map<String, String>> productTypeInfos = emisTransPlanRuleMapper
.selectProductTypeInfoByCodes(productTypes);
log.info("Setting product type names: found product type info count={}",
productTypeInfos != null ? productTypeInfos.size() : 0);
if (productTypeInfos != null && !productTypeInfos.isEmpty()) {
// 创建产品类型编码到名称的映射
Map<String, String> productTypeToNameMap = productTypeInfos.stream()
.collect(Collectors.toMap(
info -> info.get("code"),
info -> info.get("name"),
(existing, replacement) -> existing));
log.info("Setting product type names: code to name mapping count={}", productTypeToNameMap.size());
// 设置产品类型名称
rules.forEach(rule -> {
if (org.springframework.util.StringUtils.hasText(rule.getProductType())) {
String names = Arrays.stream(rule.getProductType().split(","))
.map(code -> productTypeToNameMap.getOrDefault(code, ""))
.filter(org.springframework.util.StringUtils::hasText)
.collect(Collectors.joining(","));
rule.setProductTypeName(names);
log.debug("Setting product type name: id={}, productType={}, productTypeName={}",
rule.getId(), rule.getProductType(), names);
}
});
}
}
}
/**
* 设置线路名称
*/
private void setLineName(List<EmisTransPlanRule> rules) {
if (rules == null || rules.isEmpty()) {
log.info("Setting line names: rules list is empty");
return;
}
// 收集所有需要查询的线路编码
List<String> lineCodes = rules.stream()
.map(EmisTransPlanRule::getLineCode)
.filter(org.springframework.util.StringUtils::hasText)
.distinct()
.collect(Collectors.toList());
log.info("Setting line names: code count={}, codes={}", lineCodes.size(), lineCodes);
if (!lineCodes.isEmpty()) {
// 批量查询线路信息
List<EmisTransLine> lines = emisTransLineMapper.selectEmisTransLineList(
new EmisTransLine() {
{
setLineCode(String.join(",", lineCodes));
}
});
log.info("Setting line names: found line info count={}", lines != null ? lines.size() : 0);
if (lines != null && !lines.isEmpty()) {
// 创建线路编码到线路名称的映射
Map<String, String> lineCodeToNameMap = lines.stream()
.collect(Collectors.toMap(
EmisTransLine::getLineCode,
EmisTransLine::getLineName,
(existing, replacement) -> existing));
log.info("Setting line names: code to name mapping count={}", lineCodeToNameMap.size());
// 设置线路名称
rules.forEach(rule -> {
if (org.springframework.util.StringUtils.hasText(rule.getLineCode())) {
String name = lineCodeToNameMap.get(rule.getLineCode());
rule.setLineName(name);
log.debug("Setting line name: id={}, lineCode={}, lineName={}",
rule.getId(), rule.getLineCode(), name);
}
});
}
}
}
/**
* 构建树形结构
*/
private List<EmisTransPlanRule> buildTree(List<EmisTransPlanRule> allRules) {
log.debug("Start building tree structure, node count={}", allRules != null ? allRules.size() : 0);
if (allRules == null || allRules.isEmpty()) {
return new ArrayList<>();
}
// 使用 Map 存储 ID 到节点的映射,方便查找父节点
Map<Long, EmisTransPlanRule> map = allRules.stream()
.collect(Collectors.toMap(EmisTransPlanRule::getId, rule -> rule));
List<EmisTransPlanRule> tree = new ArrayList<>();
for (EmisTransPlanRule rule : allRules) {
EmisTransPlanRule parent = map.get(rule.getParentId());
// 如果 parent 不为 null 且在当前查询结果中,则添加到父节点的 children 列表
if (parent != null) {
if (parent.getChildren() == null) {
parent.setChildren(new ArrayList<>());
}
parent.getChildren().add(rule);
log.debug("Adding child node, parentId={}, childId={}", parent.getId(), rule.getId());
}
// 否则,如果 parentId 为 0 或者父节点不在当前查询结果中,则认为是根节点
else if (rule.getParentId() == null || rule.getParentId() == 0L || !map.containsKey(rule.getParentId())) {
tree.add(rule);
log.debug("Adding root node, ID={}", rule.getId());
}
}
log.debug("Built tree structure, root node count={}", tree.size());
return tree;
}
private EmisTmsSiteBatchMiss createMissRecord(EmisWaybill waybill) {
EmisTmsSiteBatchMiss miss = new EmisTmsSiteBatchMiss();
miss.setBillCode(waybill.getBillCode());
@ -590,32 +406,12 @@ public class EmisTmsSiteBatchMissServiceImpl implements IEmisTmsSiteBatchMissSer
* @param missRecords
* @return 是否匹配
*/
private boolean checkBranchMatch(EmisTransPlanRule emisTransPlanRule, List<EmisTmsSiteBatch> waybillBatches,
private boolean checkBranchMatch(List<EmisTransPlanRule> ruleList, List<EmisTmsSiteBatch> waybillBatches,
EmisWaybill waybill, List<EmisTmsSiteBatchMiss> missRecords) {
// 检查当前节点是否匹配
boolean allNodeMatched = false;
List<EmisTransPlanRule> children1 = emisTransPlanRule.getChildren();
if (children1.isEmpty()) {
// 创建漏组记录
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
miss.setMissReason("当前线路没有创建对应的线路规划");
missRecords.add(miss);
return false;
}
List<EmisTransPlanRule> children2 = children1.stream()
.filter(i -> StringUtils.isNotBlank(i.getProductType())
&& i.getProductType().contains(waybill.getProductType()))
.collect(Collectors.toList());
if (children2.isEmpty() || children2.get(0) == null || children2.get(0).getChildren().isEmpty()) {
// 创建漏组记录
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
miss.setMissReason("当前线路没有创建对应的线路规划");
missRecords.add(miss);
return false;
}
List<EmisTransPlanRule> rules = children2.get(0).getChildren();
List<EmisTransPlanRule> filterRules = Lists.newArrayList();
for (EmisTransPlanRule rule : rules) {
for (EmisTransPlanRule rule : ruleList) {
List<EmisTransPlanRule> list = Lists.newArrayList();
if (checkRule(rule, waybillBatches, list)) {
allNodeMatched = true;
@ -636,17 +432,17 @@ public class EmisTmsSiteBatchMissServiceImpl implements IEmisTmsSiteBatchMissSer
return false;
}
EmisTransPlanRule filterRule = filterRules.get(0);
String[] ancestors = filterRule.getAncestors().split(",");
Long ancestor;
if (ancestors.length > 3) {
ancestor = Long.valueOf(ancestors[3]);
} else {
if (StringUtils.isEmpty(filterRule.getAncestors())) {
ancestor = filterRule.getId();
} else {
String[] ancestors = filterRule.getAncestors().split(",");
ancestor = Long.valueOf(ancestors[0]);
}
List<EmisTransPlanRule> ruleList = rules.stream().filter(i -> i.getId().equals(ancestor))
List<EmisTransPlanRule> rules = ruleList.stream().filter(i -> i.getId().equals(ancestor))
.collect(Collectors.toList());
EmisTransPlanRule rule = ruleList.get(0);
EmisTransPlanRule rule = rules.get(0);
setMissRecords(missRecords, rule, filterRules, waybill);
return false;
}
@ -658,7 +454,9 @@ public class EmisTmsSiteBatchMissServiceImpl implements IEmisTmsSiteBatchMissSer
for (EmisTmsSiteBatch batch : waybillBatches) {
if (rule.getStartSiteCode().equals(batch.getStartSiteCode()) &&
rule.getNextSiteCode().equals(batch.getNextSiteCode()) &&
rule.getSupplierCode().equals(batch.getSupplierCode())) {
rule.getSupplierCode().equals(batch.getSupplierCode())
&& batch.getEtd().before(rule.getEndDate())
&& !batch.getEtd().before(rule.getStartDate())) {
currentMatch = true;
list.add(rule);
break;

View File

@ -1,18 +1,16 @@
package com.xdadan.erp.emis.service.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import java.util.Arrays;
import java.util.stream.Stream;
import com.beust.jcommander.internal.Lists;
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
import com.xdadan.erp.emis.domain.exception.EmisBizError;
import com.xdadan.erp.emis.service.EmisBaseService;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -34,14 +32,11 @@ import org.slf4j.LoggerFactory;
*/
@Service
@Slf4j
public class EmisTransPlanRuleServiceImpl implements IEmisTransPlanRuleService {
public class EmisTransPlanRuleServiceImpl extends EmisBaseService implements IEmisTransPlanRuleService {
@Autowired
private EmisTransPlanRuleMapper emisTransPlanRuleMapper;
@Autowired
private EmisTransLineMapper emisTransLineMapper;
/**
* 查询供应商线路规划
*
@ -54,7 +49,6 @@ public class EmisTransPlanRuleServiceImpl implements IEmisTransPlanRuleService {
EmisTransPlanRule rule = emisTransPlanRuleMapper.selectEmisTransPlanRuleById(id);
if (rule != null) {
log.info("Found supplier route plan, ID={}", id);
setName(Collections.singletonList(rule));
} else {
log.warn("Supplier route plan not found, ID={}", id);
}
@ -62,7 +56,7 @@ public class EmisTransPlanRuleServiceImpl implements IEmisTransPlanRuleService {
}
/**
* 查询供应商线路规划列表,过滤根节点
* 查询供应商线路规划列表
*
* @param emisTransPlanRule 供应商线路规划
* @return 供应商线路规划
@ -72,182 +66,9 @@ public class EmisTransPlanRuleServiceImpl implements IEmisTransPlanRuleService {
log.info("Start querying supplier route plan list, query={}", emisTransPlanRule);
List<EmisTransPlanRule> list = emisTransPlanRuleMapper.selectEmisTransPlanRuleList(emisTransPlanRule);
log.info("Found supplier route plan list, count={}", list != null ? list.size() : 0);
setName(list);
return list;
}
/**
* 查询供应商线路规划列表,查询包括根节点
*
* @param emisTransPlanRule 供应商线路规划
* @return 供应商线路规划
*/
public List<EmisTransPlanRule> getEmisTransPlanRuleList(EmisTransPlanRule emisTransPlanRule) {
log.info("Start getting supplier route plan list, query={}", emisTransPlanRule);
List<EmisTransPlanRule> list = emisTransPlanRuleMapper.getEmisTransPlanRuleList(emisTransPlanRule);
log.info("Got supplier route plan list, count={}", list != null ? list.size() : 0);
setName(list);
return list;
}
private void setName(List<EmisTransPlanRule> list) {
setSupplierNames(list);
setProductTypeNames(list);
setLineName(list);
}
/**
* 设置供应商名称
*/
private void setSupplierNames(List<EmisTransPlanRule> rules) {
if (rules == null || rules.isEmpty()) {
log.info("Setting supplier names: rules list is empty");
return;
}
// 收集所有需要查询的供应商编码
List<String> supplierCodes = rules.stream()
.map(EmisTransPlanRule::getSupplierCode)
.filter(StringUtils::hasText)
.flatMap(code -> Arrays.stream(code.split(",")))
.distinct()
.collect(Collectors.toList());
log.info("Setting supplier names: code count={}, codes={}", supplierCodes.size(), supplierCodes);
if (!supplierCodes.isEmpty()) {
// 批量查询供应商信息
List<Map<String, String>> supplierInfos = emisTransPlanRuleMapper.selectSupplierInfoByCodes(supplierCodes);
log.info("Setting supplier names: found supplier info count={}",
supplierInfos != null ? supplierInfos.size() : 0);
if (supplierInfos != null && !supplierInfos.isEmpty()) {
// 创建供应商编码到名称的映射
Map<String, String> supplierCodeToNameMap = supplierInfos.stream()
.collect(Collectors.toMap(
info -> info.get("code"),
info -> info.get("name"),
(existing, replacement) -> existing));
log.info("Setting supplier names: code to name mapping count={}", supplierCodeToNameMap.size());
// 设置供应商名称
rules.forEach(rule -> {
if (StringUtils.hasText(rule.getSupplierCode())) {
String names = Arrays.stream(rule.getSupplierCode().split(","))
.map(code -> supplierCodeToNameMap.getOrDefault(code, ""))
.filter(StringUtils::hasText)
.collect(Collectors.joining(","));
rule.setSupplierName(names);
log.debug("Setting supplier name: id={}, supplierCode={}, supplierName={}",
rule.getId(), rule.getSupplierCode(), names);
}
});
}
}
}
/**
* 设置产品类型名称
*/
private void setProductTypeNames(List<EmisTransPlanRule> rules) {
if (rules == null || rules.isEmpty()) {
log.info("Setting product type names: rules list is empty");
return;
}
// 收集所有需要查询的产品类型编码
List<String> productTypes = rules.stream()
.map(EmisTransPlanRule::getProductType)
.filter(StringUtils::hasText)
.flatMap(type -> Arrays.stream(type.split(",")))
.distinct()
.collect(Collectors.toList());
log.info("Setting product type names: code count={}, codes={}", productTypes.size(), productTypes);
if (!productTypes.isEmpty()) {
// 批量查询产品类型信息
List<Map<String, String>> productTypeInfos = emisTransPlanRuleMapper
.selectProductTypeInfoByCodes(productTypes);
log.info("Setting product type names: found product type info count={}",
productTypeInfos != null ? productTypeInfos.size() : 0);
if (productTypeInfos != null && !productTypeInfos.isEmpty()) {
// 创建产品类型编码到名称的映射
Map<String, String> productTypeToNameMap = productTypeInfos.stream()
.collect(Collectors.toMap(
info -> info.get("code"),
info -> info.get("name"),
(existing, replacement) -> existing));
log.info("Setting product type names: code to name mapping count={}", productTypeToNameMap.size());
// 设置产品类型名称
rules.forEach(rule -> {
if (StringUtils.hasText(rule.getProductType())) {
String names = Arrays.stream(rule.getProductType().split(","))
.map(code -> productTypeToNameMap.getOrDefault(code, ""))
.filter(StringUtils::hasText)
.collect(Collectors.joining(","));
rule.setProductTypeName(names);
log.debug("Setting product type name: id={}, productType={}, productTypeName={}",
rule.getId(), rule.getProductType(), names);
}
});
}
}
}
/**
* 设置线路名称
*/
private void setLineName(List<EmisTransPlanRule> rules) {
if (rules == null || rules.isEmpty()) {
log.info("Setting line names: rules list is empty");
return;
}
// 收集所有需要查询的线路编码
List<String> lineCodes = rules.stream()
.map(EmisTransPlanRule::getLineCode)
.filter(StringUtils::hasText)
.distinct()
.collect(Collectors.toList());
log.info("Setting line names: code count={}, codes={}", lineCodes.size(), lineCodes);
if (!lineCodes.isEmpty()) {
// 批量查询线路信息
List<EmisTransLine> lines = emisTransLineMapper.selectEmisTransLineList(
new EmisTransLine() {
{
setLineCode(String.join(",", lineCodes));
}
});
log.info("Setting line names: found line info count={}", lines != null ? lines.size() : 0);
if (lines != null && !lines.isEmpty()) {
// 创建线路编码到线路名称的映射
Map<String, String> lineCodeToNameMap = lines.stream()
.collect(Collectors.toMap(
EmisTransLine::getLineCode,
EmisTransLine::getLineName,
(existing, replacement) -> existing));
log.info("Setting line names: code to name mapping count={}", lineCodeToNameMap.size());
// 设置线路名称
rules.forEach(rule -> {
if (StringUtils.hasText(rule.getLineCode())) {
String name = lineCodeToNameMap.get(rule.getLineCode());
rule.setLineName(name);
log.debug("Setting line name: id={}, lineCode={}, lineName={}",
rule.getId(), rule.getLineCode(), name);
}
});
}
}
}
/**
* 新增供应商线路规划
*
@ -255,40 +76,13 @@ public class EmisTransPlanRuleServiceImpl implements IEmisTransPlanRuleService {
* @return 结果
*/
@Override
@Transactional
public int insertEmisTransPlanRule(EmisTransPlanRule emisTransPlanRule) throws EmisBizError {
log.info("Start inserting supplier route plan, emisTransPlanRule={}", emisTransPlanRule);
// 处理父节点
if (emisTransPlanRule.getParentId() != null) {
EmisTransPlanRule parent = emisTransPlanRuleMapper
.selectEmisTransPlanRuleById(emisTransPlanRule.getParentId());
if (parent == null) {
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "Parent node does not exist");
}
// 设置祖先节点
String ancestors = parent.getAncestors() == null ? "" : parent.getAncestors();
emisTransPlanRule.setAncestors(ancestors + "," + parent.getId());
log.debug("Setting ancestors, parentId={}, ancestors={}", parent.getId(), emisTransPlanRule.getAncestors());
} else {
emisTransPlanRule.setParentId(0L);
emisTransPlanRule.setAncestors("0");
log.debug("Setting root node, parentId=0, ancestors=0");
}
// 插入当前节点
int rows = emisTransPlanRuleMapper.insertEmisTransPlanRule(emisTransPlanRule);
log.info("Inserted supplier route plan, affected rows={}, ID={}", rows, emisTransPlanRule.getId());
// 如果有子节点,递归处理
if (emisTransPlanRule.getChildren() != null && !emisTransPlanRule.getChildren().isEmpty()) {
log.info("Start processing child nodes, count={}", emisTransPlanRule.getChildren().size());
for (EmisTransPlanRule child : emisTransPlanRule.getChildren()) {
child.setParentId(emisTransPlanRule.getId());
insertEmisTransPlanRule(child);
}
}
return rows;
// 校验非空
checkCode(emisTransPlanRule);
checkDate(emisTransPlanRule);
// 检查重复
checkDuplicate(emisTransPlanRule);
return emisTransPlanRuleMapper.insertEmisTransPlanRule(emisTransPlanRule);
}
/**
@ -298,40 +92,8 @@ public class EmisTransPlanRuleServiceImpl implements IEmisTransPlanRuleService {
* @return 结果
*/
@Override
@Transactional
public int updateEmisTransPlanRule(EmisTransPlanRule emisTransPlanRule) throws EmisBizError {
log.info("Start updating supplier route plan, ID={}, emisTransPlanRule={}", emisTransPlanRule.getId(),
emisTransPlanRule);
if (emisTransPlanRule.getParentId() == null) {
int rows = emisTransPlanRuleMapper.updateEmisTransPlanRule(emisTransPlanRule);
log.info("Updated supplier route plan, affected rows={}", rows);
return rows;
}
// 检查父节点是否存在
EmisTransPlanRule parent = emisTransPlanRuleMapper
.selectEmisTransPlanRuleById(emisTransPlanRule.getParentId());
if (parent == null) {
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "Parent node does not exist");
}
// 检查是否形成循环引用
if (parent.getAncestors() != null && parent.getAncestors().contains(emisTransPlanRule.getId().toString())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "Cannot move node under its child node");
}
// 更新祖先节点
String ancestors = parent.getAncestors() == null ? "" : parent.getAncestors();
emisTransPlanRule.setAncestors(ancestors + "," + parent.getId());
log.debug("Updating ancestors, parentId={}, ancestors={}", parent.getId(), emisTransPlanRule.getAncestors());
// 更新当前节点
int rows = emisTransPlanRuleMapper.updateEmisTransPlanRule(emisTransPlanRule);
log.info("Updated supplier route plan, affected rows={}", rows);
// 更新子节点的祖先节点
updateChildrenAncestors(emisTransPlanRule);
return rows;
public int updateEmisTransPlanRule(EmisTransPlanRule emisTransPlanRule) {
return emisTransPlanRuleMapper.updateEmisTransPlanRule(emisTransPlanRule);
}
/**
@ -341,116 +103,171 @@ public class EmisTransPlanRuleServiceImpl implements IEmisTransPlanRuleService {
* @return 结果
*/
@Override
@Transactional
public int deleteEmisTransPlanRuleByIds(Long[] ids) throws EmisBizError {
log.info("Start batch deleting supplier route plans, IDs={}", Arrays.toString(ids));
for (Long id : ids) {
// 检查是否有子节点
if (emisTransPlanRuleMapper.hasChildByEmisTransPlanRuleId(id) > 0) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "Cannot delete node with child nodes");
}
deleteEmisTransPlanRuleById(id);
}
log.info("Batch deleted supplier route plans, count={}", ids.length);
return ids.length;
}
/**
* 删除供应商线路规划信息
*
* @param id 供应商线路规划主键
* @return 结果
*/
@Override
public int deleteEmisTransPlanRuleById(Long id) {
log.info("Start deleting supplier route plan, ID={}", id);
int rows = emisTransPlanRuleMapper.deleteEmisTransPlanRuleById(id);
log.info("Deleted supplier route plan, affected rows={}", rows);
return rows;
public int deleteEmisTransPlanRuleByIds(Long[] ids) {
return emisTransPlanRuleMapper.deleteEmisTransPlanRuleByIds(ids);
}
/**
* 查询供应商线路规划树结构
*
* @param lineCode 线路编码
* @param emisTransPlanRule 供应商线路规划
* @return 供应商线路规划树结构
*/
@Override
public List<EmisTransPlanRule> selectEmisTransPlanRuleTree(String lineCode) {
log.info("Start querying supplier route plan tree, lineCode={}", lineCode);
EmisTransPlanRule query = new EmisTransPlanRule();
query.setLineCode(lineCode);
List<EmisTransPlanRule> allRules = this.getEmisTransPlanRuleList(query);
List<EmisTransPlanRule> tree = buildTree(allRules);
log.info("Queried supplier route plan tree, node count={}", tree != null ? tree.size() : 0);
return tree;
}
public List<EmisTransPlanRule> selectEmisTransPlanRuleTree(EmisTransPlanRule emisTransPlanRule) {
// 查询所有规则
List<EmisTransPlanRule> allRules = emisTransPlanRuleMapper.selectEmisTransPlanRuleList(emisTransPlanRule);
/**
* 构建树形结构
*/
private List<EmisTransPlanRule> buildTree(List<EmisTransPlanRule> allRules) {
log.debug("Start building tree structure, node count={}", allRules != null ? allRules.size() : 0);
if (allRules == null || allRules.isEmpty()) {
return new ArrayList<>();
}
// 使用 Map 存储 ID 到节点的映射,方便查找父节点
Map<Long, EmisTransPlanRule> map = allRules.stream()
.collect(Collectors.toMap(EmisTransPlanRule::getId, rule -> rule));
List<EmisTransPlanRule> tree = new ArrayList<>();
for (EmisTransPlanRule rule : allRules) {
EmisTransPlanRule parent = map.get(rule.getParentId());
// 如果 parent 不为 null 且在当前查询结果中,则添加到父节点的 children 列表
if (parent != null) {
if (parent.getChildren() == null) {
parent.setChildren(new ArrayList<>());
}
parent.getChildren().add(rule);
log.debug("Adding child node, parentId={}, childId={}", parent.getId(), rule.getId());
}
// 否则,如果 parentId 为 0 或者父节点不在当前查询结果中,则认为是根节点
else if (rule.getParentId() == null || rule.getParentId() == 0L || !map.containsKey(rule.getParentId())) {
tree.add(rule);
log.debug("Adding root node, ID={}", rule.getId());
}
}
log.debug("Built tree structure, root node count={}", tree.size());
return tree;
}
/**
* 递归更新子节点的祖先节点
*/
@Transactional
public void updateChildrenAncestors(EmisTransPlanRule parent) {
log.info("Start updating children's ancestors, parentId={}", parent.getId());
// 查询直接子节点
EmisTransPlanRule childQuery = new EmisTransPlanRule();
childQuery.setParentId(parent.getId());
List<EmisTransPlanRule> children = emisTransPlanRuleMapper.getEmisTransPlanRuleList(childQuery);
log.info("Found child nodes, count={}", children != null ? children.size() : 0);
if (children != null && !children.isEmpty()) {
String newAncestors = parent.getAncestors() + "," + parent.getId();
for (EmisTransPlanRule child : children) {
child.setAncestors(newAncestors);
// 更新子节点,包括其祖先信息
emisTransPlanRuleMapper.updateEmisTransPlanRule(child);
log.debug("Updating child node's ancestors, childId={}, ancestors={}", child.getId(), newAncestors);
// 递归更新子节点
updateChildrenAncestors(child);
}
}
// 构建树形结构
return buildTree(allRules);
}
@Override
public List<EmisTransPlanRule> selectSupplierInfoByConditions(EmisTransPlanRule emisTransPlanRule) {
log.info("Start querying supplier info by conditions, query={}", emisTransPlanRule);
emisTransPlanRule.setStatus("1");
List<EmisTransPlanRule> result = this.getEmisTransPlanRuleList(emisTransPlanRule);
List<EmisTransPlanRule> result = emisTransPlanRuleMapper.selectEmisTransPlanRuleList(emisTransPlanRule);
log.info("Queried supplier info, count={}", result != null ? result.size() : 0);
return result;
}
/**
* Excel草稿方式新增
*
* @param emisTransPlanRule 供应商线路规划
* @return 结果
*/
@Override
public int draftSubmitRule(EmisTransPlanRule emisTransPlanRule) throws EmisBizError {
// 校验参数
checkName(emisTransPlanRule);
checkDate(emisTransPlanRule);
nameToCode(emisTransPlanRule);
// 检查重复
checkDuplicate(emisTransPlanRule);
return emisTransPlanRuleMapper.insertEmisTransPlanRule(emisTransPlanRule);
}
private void nameToCode(EmisTransPlanRule emisTransPlanRule) throws EmisBizError {
// 线路
List<Map<String, String>> lineInfo = emisTransPlanRuleMapper.selectLineInfoByNames(Collections.singletonList(emisTransPlanRule.getLineName()));
if (lineInfo == null || lineInfo.isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "未找到对应的线路:" + emisTransPlanRule.getLineName());
}
emisTransPlanRule.setLineCode(lineInfo.get(0).get("code"));
// 产品类型(支持多个,逗号分隔)
String[] productTypeNames = emisTransPlanRule.getProductTypeName().split(",");
List<Map<String, String>> productTypeInfo = emisTransPlanRuleMapper.selectProductTypeInfoByNames(Arrays.asList(productTypeNames));
if (productTypeInfo == null || productTypeInfo.isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "未找到对应的产品类型:" + emisTransPlanRule.getProductTypeName());
}
if (productTypeInfo.size() != productTypeNames.length) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "部分产品类型未找到:" + emisTransPlanRule.getProductTypeName());
}
String productTypeCodes = productTypeInfo.stream()
.map(map -> map.get("code"))
.collect(Collectors.joining(","));
emisTransPlanRule.setProductType(productTypeCodes);
// 起始网点
List<Map<String, String>> startSiteInfo = emisTransPlanRuleMapper.selectSiteInfoByNames(Collections.singletonList(emisTransPlanRule.getStartSiteName()));
if (startSiteInfo == null || startSiteInfo.isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "未找到对应的起始网点:" + emisTransPlanRule.getStartSiteName());
}
emisTransPlanRule.setStartSiteCode(startSiteInfo.get(0).get("code"));
// 下一网点
List<Map<String, String>> nextSiteInfo = emisTransPlanRuleMapper.selectSiteInfoByNames(Collections.singletonList(emisTransPlanRule.getNextSiteName()));
if (nextSiteInfo == null || nextSiteInfo.isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "未找到对应的下一网点:" + emisTransPlanRule.getNextSiteName());
}
emisTransPlanRule.setNextSiteCode(nextSiteInfo.get(0).get("code"));
// 供应商(支持多个,逗号分隔)
String[] supplierNames = emisTransPlanRule.getSupplierName().split(",");
List<Map<String, String>> supplierInfo = emisTransPlanRuleMapper.selectSupplierInfoByNames(Arrays.asList(supplierNames));
if (supplierInfo == null || supplierInfo.isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "未找到对应的供应商:" + emisTransPlanRule.getSupplierName());
}
if (supplierInfo.size() != supplierNames.length) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "部分供应商未找到:" + emisTransPlanRule.getSupplierName());
}
String supplierCodes = supplierInfo.stream()
.map(map -> map.get("code"))
.collect(Collectors.joining(","));
emisTransPlanRule.setSupplierCode(supplierCodes);
}
private void checkDuplicate(EmisTransPlanRule emisTransPlanRule) throws EmisBizError {
List<EmisTransPlanRule> existingRules = emisTransPlanRuleMapper.checkDuplicate(emisTransPlanRule);
if (existingRules != null && !existingRules.isEmpty()) {
throw new EmisBizError(EmisBizErrorType.EXISTS, "已存在相同的规则配置");
}
}
private static void checkName(EmisTransPlanRule emisTransPlanRule) throws EmisBizError {
if (StringUtil.isBlank(emisTransPlanRule.getManager())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "节点负责人不能为空");
}
if (StringUtil.isBlank(emisTransPlanRule.getLineName())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "线路名称不能为空");
}
if (StringUtil.isBlank(emisTransPlanRule.getProductTypeName())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "产品名称不能为空");
}
if (StringUtil.isBlank(emisTransPlanRule.getStartSiteName())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "起始网点名称不能为空");
}
if (StringUtil.isBlank(emisTransPlanRule.getNextSiteName())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "下一网点名称不能为空");
}
if (StringUtil.isBlank(emisTransPlanRule.getSupplierName())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "供应商名称不能为空");
}
}
private static void checkCode(EmisTransPlanRule emisTransPlanRule) throws EmisBizError {
if (StringUtil.isBlank(emisTransPlanRule.getManager())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "节点负责人不能为空");
}
if (StringUtil.isBlank(emisTransPlanRule.getLineCode())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "线路名称不能为空");
}
if (StringUtil.isBlank(emisTransPlanRule.getProductType())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "产品名称不能为空");
}
if (StringUtil.isBlank(emisTransPlanRule.getStartSiteCode())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "起始网点名称不能为空");
}
if (StringUtil.isBlank(emisTransPlanRule.getNextSiteCode())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "下一网点名称不能为空");
}
if (StringUtil.isBlank(emisTransPlanRule.getSupplierCode())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "供应商名称不能为空");
}
}
private static void checkDate(EmisTransPlanRule emisTransPlanRule) throws EmisBizError {
Date startDate = emisTransPlanRule.getStartDate();
Date endDate = emisTransPlanRule.getEndDate();
if (startDate == null) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "生效时间不能为空");
}
if (endDate == null) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "失效时间不能为空");
}
if (startDate.after(endDate)) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "生效时间不能晚于失效时间");
}
}
}

View File

@ -483,7 +483,7 @@
</delete>
<!-- 根据运单号列表查询组批次信息 -->
<select id="selectEmisTmsSiteBatchListByBillCodes" resultMap="EmisTmsSiteBatchResult">
<select id="selectEmisTmsSiteBatchListByBillCodes" resultMap="EmisTmsSiteBatchDtlResult">
select distinct b.*
from emis_tms_site_batch b
inner join emis_tms_site_batch_dtl d on b.batch_no = d.batch_no

View File

@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id"/>
<result property="billCode" column="bill_code"/>
<result property="manager" column="manager"/>
<result property="transManager" column="trans_manager"/>
<result property="missReason" column="miss_reason"/>
<result property="sendSiteCode" column="send_site_code"/>
<result property="sendSiteName" column="send_site_name"/>
@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
w.send_site_code, s.site_name as send_site_name, w.send_country, c1.name as send_country_name, w.destination_code, n.dest_name as destination_name,
w.receive_country, c2.name as receive_country_name, w.send_date, w.bl_sign, w.sign_date, w.trans_line_type, k.line_name as trans_line_type_name,
w.product_type, j.prod_name as product_type_name, w.payment_type, w.parcel_qty, w.bill_weight, w.total_volume, w.volume_weight,
w.settlement_weight, w.freight, w.remark as waybill_remark, w.fee_remark, r.manager
w.settlement_weight, w.freight, w.remark as waybill_remark, w.fee_remark, r.manager, k.trans_manager
from emis_tms_site_batch_miss m
left join emis_waybill w on m.bill_code = w.bill_code and w.del_flag='0'
left join emis_site s on w.send_site_code=s.site_code and s.del_flag=0
@ -72,8 +73,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="manager != null and manager != ''">
AND r.manager like concat('%', #{manager}, '%')
</if>
<if test="transManager != null and transManager != ''">
AND k.trans_manager like concat('%', #{transManager}, '%')
</if>
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
and r.manager=#{params.privEmpName}
and (r.manager=#{params.privEmpName} or k.trans_manager=#{params.privEmpName})
</if>
</where>
</select>

View File

@ -23,6 +23,7 @@
<result property="logoType" column="logo_type" />
<result property="transType" column="trans_type" />
<result property="orderNum" column="order_num" />
<result property="transManager" column="trans_manager" />
<association property="fromCountryName" column="from_country" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectCountryNameByCode"/>
<association property="countryName" column="country" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectCountryNameByCode"/>
@ -33,7 +34,7 @@
<sql id="selectEmisTransLineVo">
select id, line_code, line_name, line_name_en, meter_rate, status, site_audit_man, site_audit_man_code, market_man, market_man_code, operate_man, operate_man_code, from_country, country, apply_scope, logo_type, trans_type, order_num, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_trans_line
select id, line_code, line_name, line_name_en,trans_manager, meter_rate, status, site_audit_man, site_audit_man_code, market_man, market_man_code, operate_man, operate_man_code, from_country, country, apply_scope, logo_type, trans_type, order_num, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_trans_line
</sql>
<select id="selectEmisTransLineList" parameterType="EmisTransLine" resultMap="EmisTransLineResult">
@ -44,6 +45,7 @@
<if test="lineCode != null and lineCode != ''"> and FIND_IN_SET(line_code,#{lineCode})</if>
<if test="lineName != null and lineName != ''"> and line_name like concat('%', #{lineName}, '%')</if>
<if test="lineNameEn != null and lineNameEn != ''"> and line_name_en like concat('%', #{lineNameEn}, '%')</if>
<if test="transManager != null and transManager != ''"> and trans_manager like concat('%', #{transManager}, '%')</if>
<if test="meterRate != null and meterRate != ''"> and meter_rate=#{meterRate}</if>
<if test="status != null "> and status = #{status}</if>
<if test="siteAuditMan != null and siteAuditMan != ''"> and site_audit_man like concat('%', #{siteAuditMan}, '%')</if>
@ -72,13 +74,13 @@
</select>
<select id="selectEmisTransLineById" parameterType="Long" resultMap="EmisTransLineResult">
select id, line_code, line_name, line_name_en, meter_rate, status, site_audit_man, site_audit_man_code, market_man, market_man_code, operate_man, operate_man_code, from_country, country, apply_scope, logo_type, trans_type, order_num, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
select id, line_code, line_name, line_name_en,trans_manager meter_rate, status, site_audit_man, site_audit_man_code, market_man, market_man_code, operate_man, operate_man_code, from_country, country, apply_scope, logo_type, trans_type, order_num, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_trans_line a
where a.id = #{id}
</select>
<select id="selectTransLineByName" parameterType="String" resultMap="EmisTransLineResult">
select id, line_code, line_name, line_name_en, meter_rate, status, site_audit_man, site_audit_man_code, market_man, market_man_code, operate_man, operate_man_code, from_country, country, apply_scope, logo_type, trans_type, order_num, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
select id, line_code, line_name, line_name_en,trans_manager meter_rate, status, site_audit_man, site_audit_man_code, market_man, market_man_code, operate_man, operate_man_code, from_country, country, apply_scope, logo_type, trans_type, order_num, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_trans_line a
where a.del_flag = '0' and a.line_name = #{lineName}
</select>
@ -91,6 +93,7 @@
<if test="lineCode != null and lineCode != ''">line_code,</if>
<if test="lineName != null and lineName != ''">line_name,</if>
<if test="lineNameEn != null and lineNameEn != ''">line_name_en,</if>
<if test="transManager != null and transManager != ''">trans_manager,</if>
<if test="meterRate != null and meterRate != ''">meter_rate,</if>
<if test="status != null">status,</if>
<if test="siteAuditMan != null and siteAuditMan != ''">site_audit_man,</if>
@ -120,6 +123,7 @@
<if test="lineCode != null and lineCode != ''">#{lineCode},</if>
<if test="lineName != null and lineName != ''">#{lineName},</if>
<if test="lineNameEn != null and lineNameEn != ''">#{lineNameEn},</if>
<if test="transManager != null and trans_manager != ''">#{transManager},</if>
<if test="meterRate != null and meterRate != ''">#{meterRate},</if>
<if test="status != null">#{status},</if>
<if test="siteAuditMan != null and siteAuditMan != ''">#{siteAuditMan},</if>
@ -152,6 +156,7 @@
<if test="lineCode != null and lineCode != ''">line_code = #{lineCode},</if>
<if test="lineName != null and lineName != ''">line_name = #{lineName},</if>
<if test="lineNameEn != null and lineNameEn != ''">line_name_en = #{lineNameEn},</if>
<if test="transManager != null and transManager != ''">trans_manager = #{transManager},</if>
<if test="meterRate != null and meterRate != ''">meter_rate = #{meterRate},</if>
<if test="status != null">status = #{status},</if>
<if test="siteAuditMan != null and siteAuditMan != ''">site_audit_man = #{siteAuditMan},</if>

View File

@ -6,11 +6,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="EmisTransPlanRule" id="EmisTransPlanRuleResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
<result property="id" column="id" />
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="lineCode" column="line_code" />
<result property="lineName" column="line_name" />
<result property="transType" column="trans_type" />
<result property="productType" column="product_type" />
<result property="startSiteCode" column="start_site_code" />
<result property="startSiteName" column="start_site_name" />
@ -18,53 +15,59 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="nextSiteName" column="next_site_name" />
<result property="manager" column="manager" />
<result property="supplierCode" column="supplier_code" />
<result property="status" column="status" />
<result property="startDate" column="start_date" />
<result property="endDate" column="end_date" />
<result property="supplierName" column="supplier_name" />
<result property="productTypeName" column="product_type_name" />
</resultMap>
<sql id="selectEmisTransPlanRuleVo">
select r.id, r.parent_id, r.ancestors, r.line_code, r.trans_type, r.product_type, r.start_site_code,
s1.site_name as start_site_name, r.next_site_code, s2.site_name as next_site_name, r.manager, r.supplier_code,
r.status, r.remark, r.del_flag, r.create_by, r.create_time, r.update_by, r.update_time, r.create_site, r.update_site
select r.id, r.line_code, r.product_type, r.start_site_code,
s1.site_name as start_site_name, r.next_site_code, s2.site_name as next_site_name,
r.manager, r.supplier_code, r.start_date, r.end_date, r.remark,
r.del_flag, r.create_by, r.create_time, r.update_by, r.update_time, r.create_site, r.update_site,
l.line_name,
(SELECT GROUP_CONCAT(s.name)
FROM emis_supplier s
WHERE FIND_IN_SET(s.code, r.supplier_code)
AND s.del_flag = '0') as supplier_name,
(SELECT GROUP_CONCAT(p.prod_name)
FROM emis_trans_product p
WHERE FIND_IN_SET(p.prod_code, r.product_type)
AND p.del_flag = '0') as product_type_name
from emis_trans_plan_rule r
left join emis_site s1 on r.start_site_code = s1.site_code and s1.del_flag=0
left join emis_site s2 on r.next_site_code = s2.site_code and s2.del_flag=0
left join emis_site s1 on r.start_site_code = s1.site_code and s1.del_flag='0'
left join emis_site s2 on r.next_site_code = s2.site_code and s2.del_flag='0'
left join emis_trans_line l on r.line_code = l.line_code and l.del_flag='0'
</sql>
<select id="selectEmisTransPlanRuleList" parameterType="EmisTransPlanRule" resultMap="EmisTransPlanRuleResult">
<include refid="selectEmisTransPlanRuleVo"/>
<where>
<if test="parentId != null"> and r.parent_id = #{parentId}</if>
<if test="ancestors != null and ancestors != ''"> and r.ancestors like concat(#{ancestors}, '%')</if>
<if test="lineCode != null and lineCode != ''"> and r.line_code = #{lineCode}</if>
<if test="transType != null and transType != ''"> and ( FIND_IN_SET(#{transType},r.trans_type) )</if>
<if test="productType != null and productType != ''"> and ( FIND_IN_SET(#{productType},r.product_type) )</if>
<if test="startSiteCode != null and startSiteCode != ''"> and r.start_site_code = #{startSiteCode}</if>
<if test="nextSiteCode != null and nextSiteCode != ''"> and r.next_site_code = #{nextSiteCode}</if>
<if test="manager != null and manager != ''"> and r.manager = #{manager}</if>
<if test="supplierCode != null and supplierCode != ''"> and ( FIND_IN_SET(#{supplierCode},r.supplier_code) )</if>
<if test="status != null and status != ''"> and r.status = #{status}</if>
<if test="startDate != null"> and r.start_date = #{startDate}</if>
<if test="endDate != null"> and r.end_date = #{endDate}</if>
and r.del_flag = '0'
and LENGTH(r.ancestors) - LENGTH(REPLACE(r.ancestors, ',', '')) > 1
</where>
order by id desc
</select>
<select id="getEmisTransPlanRuleList" parameterType="EmisTransPlanRule" resultMap="EmisTransPlanRuleResult">
<select id="checkDuplicate" parameterType="EmisTransPlanRule" resultMap="EmisTransPlanRuleResult">
<include refid="selectEmisTransPlanRuleVo"/>
<where>
<if test="parentId != null"> and r.parent_id = #{parentId}</if>
<if test="ancestors != null and ancestors != ''"> and r.ancestors like concat(#{ancestors}, '%')</if>
<if test="lineCode != null and lineCode != ''"> and r.line_code = #{lineCode}</if>
<if test="transType != null and transType != ''"> and ( FIND_IN_SET(#{transType},r.trans_type) )</if>
<if test="productType != null and productType != ''"> and ( FIND_IN_SET(#{productType},r.product_type) )</if>
<if test="startSiteCode != null and startSiteCode != ''"> and r.start_site_code = #{startSiteCode}</if>
<if test="nextSiteCode != null and nextSiteCode != ''"> and r.next_site_code = #{nextSiteCode}</if>
<if test="manager != null and manager != ''"> and r.manager = #{manager}</if>
<if test="supplierCode != null and supplierCode != ''"> and ( FIND_IN_SET(#{supplierCode},r.supplier_code) )</if>
<if test="status != null and status != ''"> and r.status = #{status}</if>
<if test="lineCode != null and lineCode != ''">and r.line_code = #{lineCode}</if>
<if test="productType != null and productType != ''">and r.product_type=#{productType}</if>
<if test="startSiteCode != null and startSiteCode != ''">and r.start_site_code = #{startSiteCode}</if>
<if test="nextSiteCode != null and nextSiteCode != ''">and r.next_site_code = #{nextSiteCode}</if>
<if test="supplierCode != null and supplierCode != ''">and r.supplier_code=#{supplierCode}</if>
and r.del_flag = '0'
</where>
order by id
order by id desc
</select>
<select id="selectEmisTransPlanRuleById" parameterType="Long" resultMap="EmisTransPlanRuleResult">
@ -72,16 +75,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where r.id = #{id} and r.del_flag = '0'
</select>
<select id="selectChildrenEmisTransPlanRuleById" parameterType="Long" resultMap="EmisTransPlanRuleResult">
<include refid="selectEmisTransPlanRuleVo"/>
where r.parent_id = #{id} and r.del_flag = '0'
</select>
<select id="hasChildByEmisTransPlanRuleId" parameterType="Long" resultType="Integer">
select count(1) from emis_trans_plan_rule
where parent_id = #{id} and del_flag = '0'
</select>
<select id="selectSupplierNamesByCodes" parameterType="String" resultType="String">
SELECT GROUP_CONCAT(s.name)
FROM emis_supplier s
@ -97,16 +90,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertEmisTransPlanRule" parameterType="EmisTransPlanRule" useGeneratedKeys="true" keyProperty="id">
insert into emis_trans_plan_rule
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId != null">parent_id,</if>
<if test="ancestors != null">ancestors,</if>
<if test="lineCode != null and lineCode != ''">line_code,</if>
<if test="transType != null">trans_type,</if>
<if test="productType != null">product_type,</if>
<if test="startSiteCode != null">start_site_code,</if>
<if test="nextSiteCode != null">next_site_code,</if>
<if test="manager != null">manager,</if>
<if test="supplierCode != null">supplier_code,</if>
<if test="status != null">status,</if>
<if test="startDate != null">start_date,</if>
<if test="endDate != null">end_date,</if>
<if test="remark != null">remark,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
@ -117,16 +108,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateSite != null">update_site,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">#{parentId},</if>
<if test="ancestors != null">#{ancestors},</if>
<if test="lineCode != null and lineCode != ''">#{lineCode},</if>
<if test="transType != null">#{transType},</if>
<if test="productType != null">#{productType},</if>
<if test="startSiteCode != null">#{startSiteCode},</if>
<if test="nextSiteCode != null">#{nextSiteCode},</if>
<if test="manager != null">#{manager},</if>
<if test="supplierCode != null">#{supplierCode},</if>
<if test="status != null">#{status},</if>
<if test="startDate != null">#{startDate},</if>
<if test="endDate != null">#{endDate},</if>
<if test="remark != null">#{remark},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
@ -141,17 +130,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateEmisTransPlanRule" parameterType="EmisTransPlanRule">
update emis_trans_plan_rule
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="ancestors != null">ancestors = #{ancestors},</if>
<if test="lineCode != null and lineCode != ''">line_code = #{lineCode},</if>
<if test="transType != null">trans_type = #{transType},</if>
<if test="productType != null">product_type = #{productType},</if>
<if test="startSiteCode != null">start_site_code = #{startSiteCode},</if>
<if test="nextSiteCode != null">next_site_code = #{nextSiteCode},</if>
<if test="manager != null">manager = #{manager},</if>
<if test="supplierCode != null">supplier_code = #{supplierCode},</if>
<if test="status != null">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="productType != null and productType != ''">product_type = #{productType},</if>
<if test="startSiteCode != null and startSiteCode != ''">start_site_code = #{startSiteCode},</if>
<if test="nextSiteCode != null and nextSiteCode != ''">next_site_code = #{nextSiteCode},</if>
<if test="manager != null and manager != ''">manager = #{manager},</if>
<if test="supplierCode != null and supplierCode != ''">supplier_code = #{supplierCode},</if>
<if test="startDate != null">start_date = #{startDate},</if>
<if test="endDate != null">end_date = #{endDate},</if>
<if test="remark != null ">remark = #{remark},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
@ -163,10 +150,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
<delete id="deleteEmisTransPlanRuleById" parameterType="Long">
update emis_trans_plan_rule set del_flag = '1' where id = #{id}
</delete>
<delete id="deleteEmisTransPlanRuleByIds" parameterType="String">
update emis_trans_plan_rule set del_flag = '1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
@ -203,4 +186,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by order_num asc
</select>
<select id="selectLineInfoByNames" parameterType="java.util.List" resultType="java.util.Map">
SELECT line_code as code, line_name as name
FROM emis_trans_line
WHERE line_name IN
<foreach collection="list" item="name" open="(" separator="," close=")">
#{name}
</foreach>
AND del_flag = '0'
</select>
<select id="selectProductTypeInfoByNames" parameterType="java.util.List" resultType="java.util.Map">
SELECT prod_code as code, prod_name as name
FROM emis_trans_product
WHERE prod_name IN
<foreach collection="list" item="name" open="(" separator="," close=")">
#{name}
</foreach>
AND del_flag = '0'
</select>
<select id="selectSiteInfoByNames" parameterType="java.util.List" resultType="java.util.Map">
SELECT site_code as code, site_name as name
FROM emis_site
WHERE site_name IN
<foreach collection="list" item="name" open="(" separator="," close=")">
#{name}
</foreach>
AND del_flag = '0'
</select>
<select id="selectSupplierInfoByNames" parameterType="java.util.List" resultType="java.util.Map">
SELECT code, name
FROM emis_supplier
WHERE name IN
<foreach collection="list" item="name" open="(" separator="," close=")">
#{name}
</foreach>
AND del_flag = '0'
</select>
</mapper>

View File

@ -3198,7 +3198,7 @@
left join emis_waybill_batch_status b on a.bill_code = b.bill_code
where a.bl_sign = '1'
and a.del_flag = '0'
-- and a.bill_code="T7080300382673"
-- and a.bill_code="T7080300290222"
and (b.site_batch_status is null or b.site_batch_status != '1')
order by a.create_time desc
limit #{offset}, #{pageSize}