This commit is contained in:
linfso 2025-07-04 07:35:55 +08:00
commit f5fed5bc9f
8 changed files with 299 additions and 17 deletions

View File

@ -193,4 +193,30 @@ public class EmisQuotePriceController extends EmisBaseController
{
return toAjax(emisQuotePriceService.deleteEmisQuotePriceByQuoteIds(quoteIds));
}
/**
* 草稿导入费用报价
*/
@PreAuthorize("@ss.hasPermi('emis:emisQuotePrice:draftQuotePrice')")
@PostMapping("/draftQuotePrice")
public AjaxResult draftQuotePrice(@RequestBody EmisQuotePrice emisQuotePrice) {
JSONObject jObjOut = new JSONObject();
String result = "success";
String msg = "导入成功";
try {
emisQuotePriceService.importDraftQuotePrice(emisQuotePrice);
jObjOut.put("quoteDetail", emisQuotePrice);
} catch (EmisBizError ex) {
ex.printStackTrace();
result = "fail";
msg = ex.getErrorCode() + ":" + ex.getMessage();
} catch (Exception ex) {
ex.printStackTrace();
result = "fail";
msg = "系统异常:" + ex.getMessage();
}
jObjOut.put("result", result);
jObjOut.put("msg", msg);
return AjaxResult.success("成功", jObjOut);
}
}

View File

@ -78,4 +78,9 @@ public interface IEmisQuotePriceService
* @return 结果
*/
public int batchUpdateEmisQuotePrice(List<EmisQuotePrice> emisQuotePriceList) throws EmisBizError;
/**
* 草稿导入费用报价,带name-code转换、规则校验、重复校验
*/
void importDraftQuotePrice(EmisQuotePrice emisQuotePrice) throws EmisBizError;
}

View File

@ -14,15 +14,14 @@ import java.util.Date;
import java.util.List;
import cn.hutool.core.collection.CollectionUtil;
import com.xdadan.erp.emis.domain.EmisQuoteExpression;
import com.xdadan.erp.common.utils.DictUtils;
import com.xdadan.erp.emis.domain.*;
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
import com.xdadan.erp.emis.domain.exception.EmisBizError;
import com.xdadan.erp.emis.mapper.EmisQuoteExpressionMapper;
import com.xdadan.erp.emis.mapper.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xdadan.erp.emis.domain.EmisQuotePrice;
import com.xdadan.erp.emis.mapper.EmisQuotePriceMapper;
import com.xdadan.erp.emis.service.IEmisQuotePriceService;
import org.springframework.transaction.annotation.Transactional;
@ -41,6 +40,18 @@ public class EmisQuotePriceServiceImpl implements IEmisQuotePriceService
@Autowired
private EmisQuoteExpressionMapper emisQuoteExpressionMapper;
@Autowired
private EmisSiteMapper emisSiteMapper;
@Autowired
private EmisTransLineMapper emisTransLineMapper;
@Autowired
private EmisTransProductMapper emisTransProductMapper;
@Autowired
private EmisRegionMapper emisRegionMapper;
/**
* 查询费用报价
@ -210,4 +221,191 @@ public class EmisQuotePriceServiceImpl implements IEmisQuotePriceService
return successCount;
}
@Override
@Transactional
public void importDraftQuotePrice(EmisQuotePrice emisQuotePrice) throws EmisBizError {
// 必填项校验
checkParam(emisQuotePrice);
// 校验日期
checkDate(emisQuotePrice);
// name-code转换
nameToCode(emisQuotePrice);
// 唯一性/重复校验
List<EmisQuotePrice> listOld = emisQuotePriceMapper.checkUnique(emisQuotePrice);
if (!CollectionUtil.isEmpty(listOld)) {
String estNameStr = "";
for (EmisQuotePrice item : listOld) {
estNameStr = estNameStr + item.getQuoteName() + ",";
}
throw new EmisBizError(EmisBizErrorType.EXISTS, "报价重复[" + estNameStr + "]");
}
// 保存报价
insertEmisQuotePrice(emisQuotePrice);
// 保存表达式
if (!CollectionUtil.isEmpty(emisQuotePrice.getExprList())) {
for (EmisQuoteExpression expr : emisQuotePrice.getExprList()) {
expr.setId(null);
expr.setQuoteId(emisQuotePrice.getQuoteId());
emisQuoteExpressionMapper.insertEmisQuoteExpression(expr);
}
}
}
private void nameToCode(EmisQuotePrice emisQuotePrice) throws EmisBizError {
EmisSite useSite = emisSiteMapper.getEmisSiteByName(emisQuotePrice.getUseSiteName());
if (useSite == null) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "未找到对应的使用网点: " + emisQuotePrice.getUseSiteName());
}
emisQuotePrice.setUseSiteCode(useSite.getSiteCode());
// 线路
EmisTransLine transLine = emisTransLineMapper.selectTransLineByName(emisQuotePrice.getTransLine());
if (transLine == null) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "未找到对应的线路: " + emisQuotePrice.getTransLine());
}
emisQuotePrice.setTransLineCode(transLine.getLineCode());
// 产品类型
EmisTransProduct prod = emisTransProductMapper.selectTransProductByName(transLine.getLineCode(),
emisQuotePrice.getProdName());
if (prod == null) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "未找到对应的产品类型: " + emisQuotePrice.getProdName());
}
emisQuotePrice.setProdCode(prod.getProdCode());
// 派件区域 name-code
if (emisQuotePrice.getDispAreaName() != null && !emisQuotePrice.getDispAreaName().trim().isEmpty()) {
EmisRegion queryRegion = new EmisRegion();
queryRegion.setRegionName(emisQuotePrice.getDispAreaName());
List<EmisRegion> dispAreaList = emisRegionMapper.selectEmisRegionList(queryRegion);
if (dispAreaList == null || dispAreaList.isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "未找到对应的派件区域: " + emisQuotePrice.getDispAreaName());
}
EmisRegion dispArea = dispAreaList.get(0);
emisQuotePrice.setDispAreaId(dispArea.getId());
emisQuotePrice.setDispAreaSiteCode(dispArea.getRegionCode());
}
// 寄件区域 name-code
if (emisQuotePrice.getSendAreaName() != null && !emisQuotePrice.getSendAreaName().trim().isEmpty()) {
EmisRegion queryRegion = new EmisRegion();
queryRegion.setRegionName(emisQuotePrice.getSendAreaName());
List<EmisRegion> sendAreaList = emisRegionMapper.selectEmisRegionList(queryRegion);
if (sendAreaList == null || sendAreaList.isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "未找到对应的寄件区域: " + emisQuotePrice.getSendAreaName());
}
EmisRegion sendArea = sendAreaList.get(0);
emisQuotePrice.setSendAreaId(sendArea.getId());
emisQuotePrice.setSendAreaSiteCode(sendArea.getRegionCode());
}
// 费用类型 name-code
if (emisQuotePrice.getFeeType() != null && !emisQuotePrice.getFeeType().isEmpty()) {
String feeTypeCode = DictUtils.getDictValue("emis_fee_type", emisQuotePrice.getFeeType());
if (feeTypeCode == null || feeTypeCode.isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "费用类型无效: " + emisQuotePrice.getFeeType());
}
emisQuotePrice.setFeeType(feeTypeCode);
}
// 币种 name-code
if (emisQuotePrice.getCurrency() != null && !emisQuotePrice.getCurrency().isEmpty()) {
String currencyCode = DictUtils.getDictValue("emis_currency", emisQuotePrice.getCurrency());
if (currencyCode == null || currencyCode.isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "费用币种无效: " + emisQuotePrice.getCurrency());
}
emisQuotePrice.setCurrency(currencyCode);
}
// 计费类型 name-code
if (emisQuotePrice.getBillType() != null && !emisQuotePrice.getBillType().isEmpty()) {
String billType = emisQuotePrice.getBillType().trim();
if ("重量计费".equals(billType)) {
emisQuotePrice.setBillType("1");
} else if ("体积计费".equals(billType)) {
emisQuotePrice.setBillType("2");
} else if (!"1".equals(billType) && !"2".equals(billType)) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "计费类型无效: " + emisQuotePrice.getBillType());
}
}
// 启用状态 name-code
if (emisQuotePrice.getStatus() != null) {
Object statusObj = emisQuotePrice.getStatus();
if (statusObj instanceof String) {
String statusStr = ((String) statusObj).trim();
if ("启用".equals(statusStr)) {
emisQuotePrice.setStatus(0);
} else if ("停用".equals(statusStr)) {
emisQuotePrice.setStatus(1);
} else {
try {
int statusInt = Integer.parseInt(statusStr);
if (statusInt != 0 && statusInt != 1) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "启用状态无效: " + statusObj);
}
emisQuotePrice.setStatus(statusInt);
} catch (NumberFormatException e) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "启用状态无效: " + statusObj);
}
}
} else if (statusObj instanceof Integer) {
int statusInt = (Integer) statusObj;
if (statusInt != 0 && statusInt != 1) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "启用状态无效: " + statusObj);
}
} else {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "启用状态无效: " + statusObj);
}
}
}
private static void checkDate(EmisQuotePrice emisQuotePrice) throws EmisBizError {
Date startDate = emisQuotePrice.getStartDate();
Date endDate = emisQuotePrice.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, "开始日期不能晚于结束日期");
}
}
private static void checkParam(EmisQuotePrice emisQuotePrice) throws EmisBizError {
if (emisQuotePrice.getQuoteName() == null || emisQuotePrice.getQuoteName().trim().isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "报价名称不能为空");
}
if (emisQuotePrice.getUseSiteName() == null || emisQuotePrice.getUseSiteName().trim().isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "使用网点不能为空");
}
if (emisQuotePrice.getTransLine() == null || emisQuotePrice.getTransLine().trim().isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "线路不能为空");
}
if (emisQuotePrice.getProdName() == null || emisQuotePrice.getProdName().trim().isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "产品类型不能为空");
}
if (emisQuotePrice.getLeastPrice() == null) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "最低价格不能为空");
}
if (emisQuotePrice.getPriceType() == null || emisQuotePrice.getPriceType().trim().isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "价格取值不能为空");
}
if (emisQuotePrice.getBillType() == null || emisQuotePrice.getBillType().trim().isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "计费类型不能为空");
}
if (emisQuotePrice.getStatus() == null) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "启用状态不能为空");
}
if (emisQuotePrice.getFeeType() == null || emisQuotePrice.getFeeType().isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "费用类型不能为空");
}
if (emisQuotePrice.getCurrency() == null || emisQuotePrice.getCurrency().trim().isEmpty()) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "费用币种不能为空");
}
if (emisQuotePrice.getSendAreaId() == null) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "寄件区域不能为空");
}
if (emisQuotePrice.getDispAreaId() == null) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "派件区域不能为空");
}
}
}

View File

@ -167,7 +167,7 @@ public class EmisSettleInvoiceChRecordServiceImpl extends EmisBaseService implem
// 开票公司
vo.setInvoiceCompany(InvoiceExportHelper.mapInvoiceCompany(record.getSalerCompanyName()));
// 备注
vo.setRemark(InvoiceExportHelper.processRemark(record));
vo.setRemark(record.getApplyRemark());
// 定制备注
vo.setCustomRemark(InvoiceExportHelper.processCustomRemark(record));
// 付款日期

View File

@ -10,7 +10,10 @@ import cn.hutool.core.collection.CollectionUtil;
import com.xdadan.erp.emis.domain.*;
import com.xdadan.erp.emis.mapper.*;
import com.xdadan.erp.emis.service.EmisBaseService;
import com.xdadan.erp.emis.utils.WaybillHelper;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -67,7 +70,19 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
@Override
public List<EmisTmsSiteBatchMiss> selectEmisTmsSiteBatchMissList(EmisTmsSiteBatchMiss emisTmsSiteBatchMiss) {
log.info("Selecting TMS site batch miss list with params: {}", emisTmsSiteBatchMiss);
return emisTmsSiteBatchMissMapper.selectEmisTmsSiteBatchMissList(emisTmsSiteBatchMiss);
List<EmisTmsSiteBatchMiss> list = null;
// 如果单号不为空,则去除其他参数
if(!StringUtils.isEmpty(emisTmsSiteBatchMiss.getBillCode())){
emisTmsSiteBatchMiss.setBillCode(WaybillHelper.formatQueryValue(emisTmsSiteBatchMiss.getBillCode()));
String[] billCodeSortList = emisTmsSiteBatchMiss.getBillCode().split(",");
if(billCodeSortList.length>1){
emisTmsSiteBatchMiss.getParams().put("billCodeSortList",Arrays.asList(billCodeSortList));
}
list = emisTmsSiteBatchMissMapper.selectEmisTmsSiteBatchMissList(emisTmsSiteBatchMiss);
}else{
list = emisTmsSiteBatchMissMapper.selectEmisTmsSiteBatchMissList(emisTmsSiteBatchMiss);
}
return list;
}
/**

View File

@ -13,6 +13,7 @@ package com.xdadan.erp.emis.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import com.xdadan.erp.common.core.redis.RedissonService;
@ -220,7 +221,19 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
public int addAll(EmisTmsSiteBatch emisTmsSiteBatch) throws EmisBizError {
// 插入明细数据
if (!CollectionUtils.isEmpty(emisTmsSiteBatch.getBatchDtlList())) {
for (EmisTmsSiteBatchDtl itemDtl : emisTmsSiteBatch.getBatchDtlList()) {
List<EmisTmsSiteBatchDtl> distinctBatchDtlList = emisTmsSiteBatch.getBatchDtlList().stream()
.filter(Objects::nonNull)
.filter(item -> StringUtils.isNotBlank(item.getBillCode()))
.collect(Collectors.toMap(
EmisTmsSiteBatchDtl::getBillCode,
item -> item,
(existing, replacement) -> existing
))
.values()
.stream()
.collect(Collectors.toList());
for (EmisTmsSiteBatchDtl itemDtl : distinctBatchDtlList) {
checkSiteBatch(emisTmsSiteBatch, itemDtl.getBillCode());
itemDtl.setBatchNo(emisTmsSiteBatch.getBatchNo());
emisTmsSiteBatchDtlMapper.insertEmisTmsSiteBatchDtl(itemDtl);
@ -247,8 +260,20 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
@Override
@Transactional
public int editAll(EmisTmsSiteBatch emisTmsSiteBatch) throws EmisBizError {
List<EmisTmsSiteBatchDtl> distinctBatchDtlList = null;
if (!CollectionUtils.isEmpty(emisTmsSiteBatch.getBatchDtlList())) {
for (EmisTmsSiteBatchDtl itemDtl : emisTmsSiteBatch.getBatchDtlList()) {
distinctBatchDtlList = emisTmsSiteBatch.getBatchDtlList().stream()
.filter(Objects::nonNull)
.filter(item -> StringUtils.isNotBlank(item.getBillCode()))
.collect(Collectors.toMap(
EmisTmsSiteBatchDtl::getBillCode,
item -> item,
(existing, replacement) -> existing
))
.values()
.stream()
.collect(Collectors.toList());
for (EmisTmsSiteBatchDtl itemDtl : distinctBatchDtlList) {
checkSiteBatch(emisTmsSiteBatch, itemDtl.getBillCode());
}
}
@ -258,8 +283,8 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
if (StringUtil.isBlank(emisTmsSiteBatch.getBatchNo())) {
return 1;
}
if (CollectionUtil.isNotEmpty(emisTmsSiteBatch.getBatchDtlList())) {
for (EmisTmsSiteBatchDtl itemDtl : emisTmsSiteBatch.getBatchDtlList()) {
if (CollectionUtil.isNotEmpty(distinctBatchDtlList)) {
for (EmisTmsSiteBatchDtl itemDtl : distinctBatchDtlList) {
itemDtl.setBatchNo(emisTmsSiteBatch.getBatchNo());
emisTmsSiteBatchDtlMapper.insertEmisTmsSiteBatchDtl(itemDtl);
}

View File

@ -164,8 +164,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join emis_country c2 on w.receive_country=c2.code and c2.del_flag=0
<where>
b.site_batch_status = '1'
<if test="billCode != null and billCode != ''">
AND w.bill_code REGEXP REPLACE(#{billCode}, '\n', '|')
<if test="billCode != null and billCode != '' and ( params.billCodeSortList == null or (params.billCodeSortList != null and params.billCodeSortList.size() == 1 ) )">
and ( b.`bill_code`=#{billCode} or b.bill_code like concat('%',#{billCode}) )
</if>
<if test="params.billCodeSortList != null and params.billCodeSortList.size() > 1 ">
and b.bill_code in
<foreach collection="params.billCodeSortList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="lineCode != null and lineCode != ''">
AND w.trans_line_type = #{lineCode}
@ -225,8 +231,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</when>
</choose>
</if>
<if test="billCode != null and billCode != ''">
AND m.bill_code REGEXP REPLACE(#{billCode}, '\n', '|')
<if test="billCode != null and billCode != '' and ( params.billCodeSortList == null or (params.billCodeSortList != null and params.billCodeSortList.size() == 1 ) )">
and ( m.`bill_code`=#{billCode} or m.bill_code like concat('%',#{billCode}) )
</if>
<if test="params.billCodeSortList != null and params.billCodeSortList.size() > 1 ">
and m.bill_code in
<foreach collection="params.billCodeSortList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="missReason != null and missReason != ''">
AND m.miss_reason like concat('%', #{missReason}, '%')

View File

@ -3809,14 +3809,15 @@
select a.id, a.bill_code,a.trans_line_type, a.product_type,a.start_site_code,a.send_site_code
from emis_waybill a
left join emis_waybill_batch_status b on a.bill_code = b.bill_code
where a.bl_sign = '1'
and a.del_flag = '0'
where a.del_flag = '0'
and (b.site_batch_status is null or b.site_batch_status != '1')
<if test="lineCode != null and lineCode != ''">
and a.trans_line_type = #{lineCode}
</if>
and a.send_date <![CDATA[ > ]]> '2025-01-01 00:00:00'
and (a.virtual_remark is null or virtual_remark = '')
and a.send_date <![CDATA[ <= ]]> DATE_SUB(CURDATE(), INTERVAL 7 DAY)
and (a.virtual_remark is null or virtual_remark = '' or virtual_remark = ' ')
and (a.problem_type is null or a.problem_type != 151)
order by a.create_time desc
limit #{offset}, #{pageSize}
</select>