Browse Source

报关单、报关要素顺序

master
han\hanst 2 weeks ago
parent
commit
279ffeec3b
  1. 30
      src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java
  2. 14
      src/main/resources/mapper/ecss/CoDelMapper.xml

30
src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java

@ -2337,9 +2337,37 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
// 获取partNo列表 // 获取partNo列表
List<Map> partNos = coDelMapper.getDeclarationElements(data); List<Map> partNos = coDelMapper.getDeclarationElements(data);
List<String> partNoList = partNos.stream().map(map -> map.get("partNo").toString()).collect(Collectors.toList()); List<String> partNoList = partNos.stream().map(map -> map.get("partNo").toString()).collect(Collectors.toList());
// 按通知明细item_no顺序记录partNo出现次序后续用于稳定排序
Map<String, Integer> partNoOrderMap = new HashMap<>();
for (int i = 0; i < partNos.size(); i++) {
Map partNoMap = partNos.get(i);
String partNo = partNoMap.get("partNo") != null ? partNoMap.get("partNo").toString() : "";
if (StringUtils.isBlank(partNo)) {
continue;
}
if (!partNoOrderMap.containsKey(partNo)) {
partNoOrderMap.put(partNo, i);
}
}
// 根据partNo获取hsCode // 根据partNo获取hsCode
List<Map> hsCodes = coDelMapper.getHsCodeByPartNo(data.getSite(), partNoList); List<Map> hsCodes = coDelMapper.getHsCodeByPartNo(data.getSite(), partNoList);
Map<String, Map> hsCodeMap = new HashMap<>();
hsCodes.sort((left, right) -> {
String leftPartNo = left.get("part_no") != null ? left.get("part_no").toString() : "";
String rightPartNo = right.get("part_no") != null ? right.get("part_no").toString() : "";
Integer leftOrder = partNoOrderMap.get(leftPartNo);
Integer rightOrder = partNoOrderMap.get(rightPartNo);
if (leftOrder == null && rightOrder == null) {
return 0;
}
if (leftOrder == null) {
return 1;
}
if (rightOrder == null) {
return -1;
}
return leftOrder.compareTo(rightOrder);
});
Map<String, Map> hsCodeMap = new LinkedHashMap<>();
// 用于收集每个hsCode对应的SKU列表 // 用于收集每个hsCode对应的SKU列表
Map<String, List<String>> hsCodeSkuListMap = new HashMap<>(); Map<String, List<String>> hsCodeSkuListMap = new HashMap<>();
for (int i = 0; i < hsCodes.size(); i++) { for (int i = 0; i < hsCodes.size(); i++) {

14
src/main/resources/mapper/ecss/CoDelMapper.xml

@ -703,6 +703,10 @@ create_by,create_date,update_by,update_date
ecss_CoDelNotifyDetail a left join part b on a.site=b.site and a.part_no=b.part_no ecss_CoDelNotifyDetail a left join part b on a.site=b.site and a.part_no=b.part_no
where a.site =#{site} and a.delNo=#{delNo} and a.qty>0 and a.bu_no=#{buNo} where a.site =#{site} and a.delNo=#{delNo} and a.qty>0 and a.bu_no=#{buNo}
GROUP BY b.hsCodeDesc,b.hsCode,b.brand,LEFT(a.currency,3) GROUP BY b.hsCodeDesc,b.hsCode,b.brand,LEFT(a.currency,3)
ORDER BY
CASE WHEN MIN(TRY_CONVERT(BIGINT, a.item_no)) IS NULL THEN 1 ELSE 0 END,
MIN(TRY_CONVERT(BIGINT, a.item_no)),
MIN(a.item_no)
</select> </select>
<select id="getDefaultEcssDeclarationDetailDataTX" resultType="EcssDeclarationDetailData"> <select id="getDefaultEcssDeclarationDetailDataTX" resultType="EcssDeclarationDetailData">
@ -758,6 +762,10 @@ create_by,create_date,update_by,update_date
ecss_CoDelNotifyDetail a left join part b on a.site=b.site and a.part_no=b.part_no ecss_CoDelNotifyDetail a left join part b on a.site=b.site and a.part_no=b.part_no
where a.site =#{site} and a.delNo=#{delNo} and a.qty>0 and a.bu_no=#{buNo} where a.site =#{site} and a.delNo=#{delNo} and a.qty>0 and a.bu_no=#{buNo}
GROUP BY b.hsCodeDesc,b.hsCode,b.brand,b.ecss_umid,LEFT(a.currency,3) GROUP BY b.hsCodeDesc,b.hsCode,b.brand,b.ecss_umid,LEFT(a.currency,3)
ORDER BY
CASE WHEN MIN(TRY_CONVERT(BIGINT, a.item_no)) IS NULL THEN 1 ELSE 0 END,
MIN(TRY_CONVERT(BIGINT, a.item_no)),
MIN(a.item_no)
</select> </select>
@ -954,10 +962,14 @@ create_by,create_date,update_by,update_date
</select> </select>
<select id="getDeclarationElements" resultType="java.util.Map"> <select id="getDeclarationElements" resultType="java.util.Map">
select part_no as partNo,bu_no as buNo
select part_no as partNo,bu_no as buNo,MIN(item_no) as itemNo
from ecss_CoDelNotifyDetail from ecss_CoDelNotifyDetail
where site=#{site} and delNo=#{delNo} and qty>0 where site=#{site} and delNo=#{delNo} and qty>0
GROUP BY part_no,bu_no GROUP BY part_no,bu_no
ORDER BY
CASE WHEN MIN(TRY_CONVERT(BIGINT, item_no)) IS NULL THEN 1 ELSE 0 END,
MIN(TRY_CONVERT(BIGINT, item_no)),
MIN(item_no)
</select> </select>
<select id="getHsCodeByPartNo" resultType="java.util.Map"> <select id="getHsCodeByPartNo" resultType="java.util.Map">

Loading…
Cancel
Save