Merge pull request 'demand: 业务确认账单报错修复' (#253) from develop into master

Reviewed-on: http://git.xdadan.loc/tanex/emis-service/pulls/253
This commit is contained in:
heyu 2025-12-05 17:41:25 +08:00
commit 005dbacf09
11 changed files with 571 additions and 65 deletions

View File

@ -966,46 +966,11 @@ public class EmisCommonController extends EmisBaseController
// 这样即使异步任务没有正确清除状态,也会在30分钟后自动过期
redissonService.setStr(statusKey, "RUNNING", 1800);
// 如果lineCode为空,查询所有线路的lineCode,去重后循环调用
if (StringUtils.isEmpty(lineCode)) {
log.info("lineCode is empty, querying all line codes");
emisTmsSiteBatchMissMapper.deleteReally(lineCode);
EmisTransLine queryLine = new EmisTransLine();
// queryLine.setStatus(1); // 只查询启用的线路
List<EmisTransLine> lineList = emisTransLineService.selectEmisTransLineList(queryLine);
// 异步执行任务
emisTmsSiteBatchMissService.autoScanSiteBatch(lineCode);
log.info("autoScanSiteBatch async task started");
// 提取lineCode并去重
Set<String> lineCodeSet = new LinkedHashSet<>();
if (!CollectionUtils.isEmpty(lineList)) {
for (EmisTransLine line : lineList) {
if (StringUtils.isNotEmpty(line.getLineCode())) {
lineCodeSet.add(line.getLineCode());
}
}
}
log.info("Found {} unique line codes, starting batch processing", lineCodeSet.size());
// 循环调用
for (String code : lineCodeSet) {
try {
emisTmsSiteBatchMissService.autoScanSiteBatch(code);
log.info("autoScanSiteBatch processed for lineCode: {}", code);
} catch (Exception e) {
log.error("autoScanSiteBatch failed for lineCode: {}, error: {}", code, e.getMessage());
// 继续处理下一个,不中断整个流程
}
}
log.info("autoScanSiteBatch async task started for all line codes");
return AjaxResult.success("异步任务已启动,共处理 " + lineCodeSet.size() + " 个线路,请稍后查看执行结果");
} else {
emisTmsSiteBatchMissMapper.deleteReally(lineCode);
// 异步执行任务
emisTmsSiteBatchMissService.autoScanSiteBatch(lineCode);
log.info("autoScanSiteBatch async task started for lineCode: {}", lineCode);
return AjaxResult.success("异步任务已启动,请稍后查看执行结果");
}
return AjaxResult.success("异步任务已启动,请稍后查看执行结果");
} catch (Exception ex) {
ex.printStackTrace();

View File

@ -1,8 +1,13 @@
package com.xdadan.erp.web.emis;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.xdadan.erp.common.core.redis.RedissonService;
import com.xdadan.erp.emis.domain.exception.EmisBizError;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -26,6 +31,7 @@ import com.xdadan.erp.common.core.page.TableDataInfo;
*
* @author heyu
*/
@Slf4j
@RestController
@RequestMapping("/emis/emisTmsSiteBatchMiss")
public class EmisTmsSiteBatchMissController extends EmisBaseController {
@ -33,6 +39,9 @@ public class EmisTmsSiteBatchMissController extends EmisBaseController {
@Autowired
private IEmisTmsSiteBatchMissService emisTmsSiteBatchMissService;
@Autowired
RedissonService redissonService;
/**
* 查询TMS漏组批次信息列表
*/
@ -282,4 +291,50 @@ public class EmisTmsSiteBatchMissController extends EmisBaseController {
emisTmsSiteBatchMissService.cancelConfirmBatchV2(billCodes);
return AjaxResult.success("取消确认成功");
}
/**
* 一键重算-V2
*
* @return
*/
@GetMapping("/autoScanSiteBatchV2")
@PreAuthorize("@ss.hasPermi('emis:emisTmsSiteBatchMiss:autoScanSiteBatchV2')")
public AjaxResult autoScanSiteBatchV2(String lineCode) {
// 检查员工代码权限
String empCode = getLoginUser().getUser().getEmpCode();
Set<String> allowedEmpCodes = new HashSet<>(Arrays.asList("88888059", "88888083", "88888102", "88888112"));
if (empCode == null || !allowedEmpCodes.contains(empCode)) {
log.warn("autoScanSiteBatchV2 access denied for empCode: {}", empCode);
return AjaxResult.error("您未被授权,如确有需要,请联系IT处理");
}
String statusKey = "autoScanSiteBatchV2_status";
log.info("autoScanSiteBatchV2 start");
// 检查任务是否正在执行
String currentStatus = redissonService.getStr(statusKey);
if ("RUNNING".equals(currentStatus)) {
log.warn("autoScanSiteBatchV2 is already running, request rejected");
return AjaxResult.error("任务正在执行中,请稍后再试");
}
try {
// 设置任务状态为运行中,设置较长的过期时间(30分钟)
// 这样即使异步任务没有正确清除状态,也会在30分钟后自动过期
redissonService.setStr(statusKey, "RUNNING", 1800);
// 异步执行任务
emisTmsSiteBatchMissService.autoScanSiteBatchV2(lineCode);
log.info("autoScanSiteBatchV2 async task started");
return AjaxResult.success("异步任务已启动,请稍后查看执行结果");
} catch (Exception ex) {
ex.printStackTrace();
log.error("autoScanSiteBatchV2 exception:" + ex.getMessage());
// 如果启动失败,清除状态
redissonService.setStr(statusKey, "", 0);
return AjaxResult.error("任务启动失败:" + ex.getMessage());
}
}
}

View File

@ -46,6 +46,7 @@ import com.xdadan.erp.emis.utils.WaybillHelper;
import com.xdadan.erp.system.domain.SysFileInfo;
import com.xdadan.erp.system.service.ISysFileInfoService;
import com.xdadan.erp.system.service.ISysUserService;
import com.xdadan.erp.web.emis.annotation.WaybillLightCount;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
@ -541,10 +542,11 @@ public class EmisWaybillController extends EmisBaseController
*/
@PreAuthorize("@ss.hasPermi('emis:emisWaybill:list')")
@GetMapping("/list")
@WaybillLightCount
public TableDataInfo list(EmisWaybill emisWaybill)
{
// 非总部只能查看自己的或者与自己相关的订单
startPage();
// startPage();
setPrivParams(emisWaybill);
@ -578,11 +580,12 @@ public class EmisWaybillController extends EmisBaseController
*/
@PreAuthorize("@ss.hasPermi('emis:emisWaybill:list')")
@GetMapping("/listOrder")
@WaybillLightCount
public TableDataInfo listOrder(EmisWaybill emisWaybill)
{
// 非总部只能查看自己的或者与自己相关的订单
startPage();
// startPage();
setPrivParams(emisWaybill);
@ -680,11 +683,12 @@ public class EmisWaybillController extends EmisBaseController
*/
@PreAuthorize("@ss.hasPermi('emis:emisWaybill:list')")
@GetMapping("/querySignlist")
@WaybillLightCount
public TableDataInfo querySignlist(EmisWaybill emisWaybill)
{
// 非总部只能查看自己的或者与自己相关的订单
startPage();
// startPage();
// 设置通用权限查询参数
setPrivParams(emisWaybill);
@ -891,9 +895,10 @@ public class EmisWaybillController extends EmisBaseController
// ,"printManName"
// },value= EmisWaybill.class,type= JacksonFilter.JscksonFilterType.RESPONSE)
@GetMapping("/queryPrintListSimple")
@WaybillLightCount
public TableDataInfo queryPrintListSimple(EmisWaybill emisWaybill)
{
startPage();
// startPage();
List<EmisWaybill> list = null;
// 如果单号不为空,则去除其他参数

View File

@ -0,0 +1,14 @@
package com.xdadan.erp.web.emis.annotation;
import java.lang.annotation.*;
/**
* 运单查询轻量 count 注解
* - 在控制器方法上使用,统一采用轻量 count 查询
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface WaybillLightCount {
}

View File

@ -0,0 +1,81 @@
package com.xdadan.erp.web.emis.aspect;
import com.github.pagehelper.PageHelper;
import com.xdadan.erp.common.core.page.PageDomain;
import com.xdadan.erp.common.core.page.TableDataInfo;
import com.xdadan.erp.common.core.page.TableSupport;
import com.xdadan.erp.emis.domain.EmisWaybill;
import com.xdadan.erp.emis.service.IEmisWaybillService;
import com.xdadan.erp.web.emis.annotation.WaybillLightCount;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
/**
* 运单查询轻量 count 切面
* - 统一关闭 PageHelper 自动 count
* - 使用轻量 count SQL 计算总数
*/
@Aspect
@Component
@Slf4j
@RequiredArgsConstructor
public class WaybillLightCountAspect {
private final IEmisWaybillService emisWaybillService;
@Pointcut("@annotation(com.xdadan.erp.web.emis.annotation.WaybillLightCount)")
public void lightCountPointcut() {}
@Around("lightCountPointcut()")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
// 统一分页:禁用自动 count,保留 orderBy
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
String orderBy = pageDomain.getOrderBy();
if (pageNum != null && pageSize != null) {
PageHelper.startPage(pageNum, pageSize, false);
if (StringUtils.isNotEmpty(orderBy)) {
PageHelper.orderBy(orderBy);
}
}
Object result = joinPoint.proceed();
if (!(result instanceof TableDataInfo)) {
return result;
}
EmisWaybill param = null;
for (Object arg : joinPoint.getArgs()) {
if (arg instanceof EmisWaybill) {
param = (EmisWaybill) arg;
break;
}
}
if (param == null) {
return result;
}
long total = 0L;
try {
total = emisWaybillService.countWaybillList(param);
} catch (Exception ex) {
log.warn("Light count failed, fallback to current total. param={}", param.getBillCode(), ex);
}
TableDataInfo table = (TableDataInfo) result;
if (total > 0) {
table.setTotal(total);
}
return table;
}
}

View File

@ -141,6 +141,11 @@ public interface EmisWaybillMapper extends BaseMapper<EmisWaybill>
public List<EmisWaybill> selectPrintWaybillList(EmisWaybill emisWaybill);
/**
* 运单列表轻量计数
*/
public long countWaybillList(EmisWaybill emisWaybill);

View File

@ -251,6 +251,7 @@ public interface IEmisWaybillService extends IDataAuditService
public List<EmisWaybill> selectPrintWaybillList(EmisWaybill emisWaybill);
public long countWaybillList(EmisWaybill emisWaybill);
public void genWarehouseInTplFileByOms(HttpServletResponse response, String orderSn,String fileType) throws EmisBizError ;
public void genWarehouseInTplFile(HttpServletResponse response, String orderSn,String fileType) throws EmisBizError ;

View File

@ -233,7 +233,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
}
// 1) 逻辑删除漏组批次数据
emisTmsSiteBatchMissMapper.deleteByBillCodes(billCodes);
// emisTmsSiteBatchMissMapper.deleteByBillCodes(billCodes);
emisTmsSiteBatchMissMapper.deleteByBillCodesV2(billCodes);
// 2) 新增运单组批次状态 site_batch_status=1(幂等:insert ignore)
@ -275,7 +275,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
// 3) 调用scanSiteBatchByWaybills重新扫描
if (!waybills.isEmpty()) {
this.scanSiteBatchByWaybills(waybills);
// this.scanSiteBatchByWaybills(waybills);
this.scanSiteBatchByWaybillsV2(waybills);
}
}
@ -307,6 +307,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
public void autoScanSiteBatch(String lineCode) {
ExecutorService executorService = null;
try {
emisTmsSiteBatchMissMapper.deleteReally(lineCode);
long startTime = System.currentTimeMillis();
int pageSize = 1000;
int offset = 0;
@ -321,20 +322,6 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
List<EmisTransPlanRule> treeRules = this.selectEmisTransPlanRuleTree(lineCode);
if (treeRules.isEmpty()) {
log.info("No trans plan rules found, skip auto scan");
List<EmisWaybill> waybills = emisWaybillMapper.selectWaybillListBySiteBatchStatus(0, 100000,
lineCode);
if (waybills.isEmpty()) {
return;
}
List<EmisTmsSiteBatchMiss> missRecords = waybills.stream().map(waybill -> {
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
miss.setMissReason("当前线路没有创建对应的线路规划");
miss.setMissType("1");
miss.setLineCode(waybill.getTransLineType());
miss.setProductType(waybill.getProductType());
return miss;
}).collect(Collectors.toList());
emisTmsSiteBatchMissMapper.batchInsertEmisTmsSiteBatchMiss(missRecords);
return;
}

View File

@ -11,6 +11,7 @@
package com.xdadan.erp.emis.service.impl;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
@ -444,6 +445,36 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
if (CollectionUtil.isEmpty(filterList)) {
throw new EmisBizError(EmisBizErrorType.FAIL, emisWaybill.getBillCode() + "组批次起始网点、下一网点、供应商与规则不匹配");
}
// 过滤有效期内的规则
Date etd = oldSiteBatch.getEtd();
if (etd != null) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List<String> validRanges = filterList.stream().map(i -> {
Date startDate = i.getStartDate();
Date endDate = i.getEndDate();
if (startDate == null || endDate == null) {
return null;
}
return sdf.format(startDate) + "~" + sdf.format(endDate);
}).filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList());
filterList = filterList.stream()
.filter(i -> {
Date startDate = i.getStartDate();
Date endDate = i.getEndDate();
if (startDate == null || endDate == null) {
return false;
}
// 判断etd是否在有效期内:startDate <= etd < endDate
return !etd.before(startDate) && etd.before(endDate);
})
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(filterList)) {
String rangeMsg = CollectionUtil.isEmpty(validRanges) ? "暂无可用时间范围"
: String.join(",", validRanges);
throw new EmisBizError(EmisBizErrorType.FAIL,
emisWaybill.getBillCode() + "组批次发出时间不在规则有效期内(规则时间范围:" + rangeMsg + "),请选择正确的时间或联系it处理");
}
}
return list;
}

View File

@ -14,6 +14,7 @@ package com.xdadan.erp.emis.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.beust.jcommander.internal.Lists;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.deepoove.poi.data.PictureType;
@ -1001,7 +1002,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
// 取件员或操作员
if ("1".equals(pickupMethod)) {
SysUser empUser = getEmisStaffBySiteCodeAndEmpName(getCurrentUser().getOwnerSiteCode(), emisWaybillSave.getOperateEmployeeCode());
SysUser empUser = getEmisStaffBySiteCodeAndEmpName(emisWaybillSave.getStartSiteCode(), emisWaybillSave.getOperateEmployeeCode());
if (empUser == null) {
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "操作员不正确");
}
@ -1010,7 +1011,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
}
emisWaybillSave.setOperateEmployeeCode(empUser.getEmpCode());
} else if ("2".equals(pickupMethod)) {
SysUser empUser = getEmisStaffBySiteCodeAndEmpName(getCurrentUser().getOwnerSiteCode(), emisWaybillSave.getOperateEmployeeCode());
SysUser empUser = getEmisStaffBySiteCodeAndEmpName(emisWaybillSave.getStartSiteCode(), emisWaybillSave.getOperateEmployeeCode());
if (empUser == null) {
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "取件员不正确");
}
@ -3814,6 +3815,13 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
@Override
public void reUpdateWayBill(EmisWaybill oldEmisWaybill,EmisWaybill emisWaybillSave,Boolean needUpdateAttach,Boolean isForce) throws EmisBizError {
// if(!emisWaybillSave.getProductType().equals(oldEmisWaybill.getProductType())){
// List<EmisTmsSiteBatch> batchList = emisTmsSiteBatchMapper.selectEmisTmsSiteBatchListByBillCodes(
// Lists.newArrayList(Collections.singleton(emisWaybillSave.getBillCode())));
// if (CollectionUtil.isNotEmpty(batchList)) {
// throw new EmisBizError(EmisBizErrorType.FAIL, "该单号已经录入批次,请先在组批次中剔除该运单");
// }
// }
// 公共计算部分
emisWaybillSave.setId(oldEmisWaybill.getId());
@ -4549,6 +4557,11 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
return emisWaybillMapper.selectPrintWaybillList(emisWaybill);
}
@Override
public long countWaybillList(EmisWaybill emisWaybill){
return emisWaybillMapper.countWaybillList(emisWaybill);
}
@Override
public void genWarehouseInTplFileByOms(HttpServletResponse response, String orderSn,String fileType) throws EmisBizError {

View File

@ -1568,6 +1568,356 @@
</select>
<select id="countWaybillList" parameterType="EmisWaybill" resultType="long">
select count(1)
from emis_waybill a
left join emis_customer_user a4 on a.cust_no=a4.monthly_pay_code and a4.del_flag='0'
left join emis_waybill_other wss on a.id=wss.waybill_id and wss.del_flag='0'
<where>
a.del_flag='0' and a.order_status !='0' and a.order_status!='2'
<if test="id != null "> and a.id = #{id}</if>
<if test="orderSn != null and orderSn != ''"> and ( FIND_IN_SET(`order_sn`,#{orderSn}) or order_sn like concat('%', #{orderSn}, '%') ) </if>
<if test="billCode != null and billCode != '' and ( params.billCodeSortList == null or (params.billCodeSortList != null and params.billCodeSortList.size() == 1 ) )">
and ( a.`bill_code`=#{billCode} or a.bill_code like concat('%',#{billCode}) )
</if>
<if test="params.billCodeSortList != null and params.billCodeSortList.size() > 1 ">
and a.bill_code in
<foreach collection="params.billCodeSortList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="custOrderId != null and custOrderId != ''"> and cust_order_id=#{custOrderId}</if>
<if test="billCodeSub != null and billCodeSub != ''"> and bill_code_sub like concat('%', #{billCodeSub}, '%')</if>
<if test="orderStatus != null and orderStatus != ''"> and order_status=#{orderStatus}</if>
<if test="waybillStatus != null and waybillStatus != ''"> and waybill_status=#{waybillStatus}</if>
<if test="orderType != null and orderType != ''"> and order_type=#{orderType}</if>
<if test="orderDate != null "> and order_date = #{orderDate}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="customerCode != null and customerCode != ''"> and customer_code=#{customerCode}</if>
<if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
<if test="openId != null and openId != ''"> and open_id like concat('%', #{openId}, '%')</if>
<if test="receiveName != null and receiveName != ''"> and receive_name like concat('%', #{receiveName}, '%')</if>
<if test="receiveCompany != null and receiveCompany != ''"> and receive_company like concat('%', #{receiveCompany}, '%')</if>
<if test="receiveMobile != null and receiveMobile != ''"> and receive_mobile like concat('%', #{receiveMobile}, '%')</if>
<if test="receiveTel != null and receiveTel != ''"> and receive_tel like concat('%', #{receiveTel}, '%')</if>
<if test="receiveCountry != null and receiveCountry != ''"> and receive_country=#{receiveCountry}</if>
<if test="receiveProvince != null and receiveProvince != ''"> and receive_province=#{receiveProvince}</if>
<if test="receiveCity != null and receiveCity != ''"> and receive_city=#{receiveCity}</if>
<if test="receiveCounty != null and receiveCounty != ''"> and receive_county=#{receiveCounty}</if>
<if test="receiveTown != null and receiveTown != ''"> and receive_town=#{receiveTown}</if>
<if test="receiveAddress != null and receiveAddress != ''"> and receive_address like concat('%', #{receiveAddress}, '%')</if>
<if test="receivePostcode != null and receivePostcode != ''"> and receive_postcode like concat('%', #{receivePostcode}, '%')</if>
<if test="receivePcd != null and receivePcd != ''"> and receive_pcd like concat('%', #{receivePcd}, '%')</if>
<if test="sendName != null and sendName != ''"> and send_name like concat('%', #{sendName}, '%')</if>
<if test="sendCompany != null and sendCompany != ''"> and send_company like concat('%', #{sendCompany}, '%')</if>
<if test="sendMobile != null and sendMobile != ''"> and send_mobile like concat('%', #{sendMobile}, '%')</if>
<if test="sendTel != null and sendTel != ''"> and send_tel like concat('%', #{sendTel}, '%')</if>
<if test="sendCountry != null and sendCountry != ''"> and send_country=#{sendCountry}</if>
<if test="sendProvince != null and sendProvince != ''"> and send_province=#{sendProvince}</if>
<if test="sendCity != null and sendCity != ''"> and send_city=#{sendCity}</if>
<if test="sendCounty != null and sendCounty != ''"> and send_county=#{sendCounty}</if>
<if test="sendTown != null and sendTown != ''"> and send_town=#{sendTown}</if>
<if test="blVirtual ==1"> and bl_virtual=#{blVirtual}</if>
<if test="sendAddress != null and sendAddress != ''"> and send_address like concat('%', #{sendAddress}, '%')</if>
<if test="sendPostcode != null and sendPostcode != ''"> and send_postcode like concat('%', #{sendPostcode}, '%')</if>
<if test="enterpriseName != null and enterpriseName != ''"> and a.enterprise_name like concat('%', #{enterpriseName}, '%')</if>
<if test="enterpriseTaxId != null and enterpriseTaxId != ''"> and a.enterprise_tax_id like concat('%', #{enterpriseTaxId}, '%')</if>
<if test="paymentType != null and paymentType != ''"> and FIND_IN_SET(payment_type,#{paymentType})</if>
<if test="calcFeeType != null and calcFeeType != ''"> and calc_fee_type=#{calcFeeType}</if>
<if test="custNo != null and custNo != ''"> and cust_no like concat('%', #{custNo}, '%')</if>
<if test="custName != null and custName != ''"> and cust_name like concat('%', #{custName}, '%')</if>
<include refid="salesSupportFilter"/>
<if test="transLineType != null and transLineType != ''"> and trans_line_type=#{transLineType}</if>
<if test="productType != null and productType != ''"> and FIND_IN_SET(product_type,#{productType})</if>
<if test="timeType != null and timeType != ''"> and time_type like concat('%', #{timeType}, '%')</if>
<if test="meterType != null and meterType != ''"> and meter_type=#{meterType}</if>
<if test="carryType != null and carryType != ''">and FIND_IN_SET(a.carry_type,#{carryType})</if>
<if test="customsClear != null and customsClear != ''"> and customs_clear=#{customsClear}</if>
<if test="customsEclaration != null and customsEclaration != ''"> and customs_eclaration=#{customsEclaration}</if>
<if test="estimateDate != null "> and estimate_date = #{estimateDate}</if>
<if test="packType != null and packType != ''"> and FIND_IN_SET(#{packType},pack_type)</if>
<if test="dispatchMethod != null and dispatchMethod != ''"> and dispatch_method=#{dispatchMethod}</if>
<if test="pickupMethod != null and pickupMethod != ''"> and pickup_method= #{pickupMethod}</if>
<if test="pickStartDate != null "> and pick_start_date = #{pickStartDate}</if>
<if test="pickFinishDate != null "> and pick_finish_date = #{pickFinishDate}</if>
<if test="pickFailReason != null and pickFailReason != ''"> and pick_fail_reason like concat('%', #{pickFailReason}, '%')</if>
<if test="intoWarehouseCode != null and intoWarehouseCode != ''"> and into_warehouse_code like concat('%', #{intoWarehouseCode}, '%')</if>
<if test="intoWarehouseName != null and intoWarehouseName != ''"> and into_warehouse_name like concat('%', #{intoWarehouseName}, '%')</if>
<if test="intoWarehouseAddress != null and intoWarehouseAddress != ''"> and into_warehouse_address like concat('%', #{intoWarehouseAddress}, '%')</if>
<if test="intoWarehouseContact != null and intoWarehouseContact != ''"> and into_warehouse_contact like concat('%', #{intoWarehouseContact}, '%')</if>
<if test="intoWarehousePhone != null and intoWarehousePhone != ''"> and into_warehouse_phone like concat('%', #{intoWarehousePhone}, '%')</if>
<if test="intoWarehouseBillCode != null and intoWarehouseBillCode != ''"> and into_warehouse_bill_code like concat('%', #{intoWarehouseBillCode}, '%')</if>
<if test="warehouseInNo != null and warehouseInNo != ''"> and warehouse_in_no like concat('%', #{warehouseInNo}, '%')</if>
<if test="customerDeliveryBeginTime != null and customerDeliveryBeginTime != ''"> and customer_delivery_begin_time like concat('%', #{customerDeliveryBeginTime}, '%')</if>
<if test="customerDeliveryEndTime != null and customerDeliveryEndTime != ''"> and customer_delivery_end_time like concat('%', #{customerDeliveryEndTime}, '%')</if>
<if test="goodsInfo != null and goodsInfo != ''"> and goods_info like concat('%', #{goodsInfo}, '%')</if>
<if test="blPrepareInFreight != null and blPrepareInFreight != ''"> and bl_prepare_in_freight=#{blPrepareInFreight}</if>
<if test="prepareInEstFee != null "> and prepare_in_est_fee = #{prepareInEstFee}</if>
<if test="prepareInRealFee != null "> and prepare_in_real_fee = #{prepareInRealFee}</if>
<if test="prepareInExpress != null and prepareInExpress != ''"> and prepare_in_express like concat('%', #{prepareInExpress}, '%')</if>
<if test="prepareInBillCode != null and prepareInBillCode != ''"> and prepare_in_bill_code like concat('%', #{prepareInBillCode}, '%')</if>
<if test="prepareInRemark != null and prepareInRemark != ''"> and prepare_in_remark like concat('%', #{prepareInRemark}, '%')</if>
<if test="prepareInSupplier != null and prepareInSupplier != ''"> and prepare_in_supplier like concat('%', #{prepareInSupplier}, '%')</if>
<if test="totalWeight != null "> and total_weight = #{totalWeight}</if>
<if test="totalVolume != null "> and total_volume = #{totalVolume}</if>
<if test="parcelQty != null "> and parcel_qty = #{parcelQty}</if>
<if test="billWeight != null "> and bill_weight = #{billWeight}</if>
<if test="volumeWeight != null "> and volume_weight = #{volumeWeight}</if>
<if test="currency != null and currency != ''"> and currency= #{currency}</if>
<if test="settlementWeight != null "> and settlement_weight = #{settlementWeight}</if>
<if test="scanWeight != null "> and scan_weight = #{scanWeight}</if>
<if test="feeWeight != null "> and fee_weight = #{feeWeight}</if>
<if test="freight != null "> and freight = #{freight}</if>
<if test="realPaymentType != null and realPaymentType != ''"> and real_payment_type=#{realPaymentType}</if>
<if test="realFee != null "> and real_fee = #{realFee}</if>
<if test="blSpecialQuote != null and blSpecialQuote != ''"> and bl_special_quote=#{blSpecialQuote}</if>
<if test="blOverLong != null and blOverLong != ''"> and bl_over_long=#{blOverLong}</if>
<if test="blBill != null and blBill != ''"> and bl_bill=#{blBill}</if>
<if test="blBillText != null and blBillText != ''"> and bl_bill_text like concat('%', #{blBillText}, '%')</if>
<if test="blOverWeight != null and blOverWeight != ''"> and bl_over_weight like concat('%', #{blOverWeight}, '%')</if>
<if test="overWeightNumber != null and overWeightNumber != ''"> and over_weight_number like concat('%', #{overWeightNumber}, '%')</if>
<if test="feeRemark != null and feeRemark != ''"> and fee_remark like concat('%', #{feeRemark}, '%')</if>
<if test="thirdCode != null and thirdCode != ''"> and third_code like concat('%', #{thirdCode}, '%')</if>
<if test="realValue != null and realValue != ''"> and real_value like concat('%', #{realValue}, '%')</if>
<if test="blInsure != null and blInsure != ''"> and bl_insure= #{blInsure}</if>
<if test="insureValue != null and insureValue != ''"> and insure_value like concat('%', #{insureValue}, '%')</if>
<if test="insureValueCurrency != null and insureValueCurrency != ''"> and insure_value_currency like concat('%', #{insureValueCurrency}, '%')</if>
<if test="insureFeeCurrency != null and insureFeeCurrency != ''"> and insure_fee_currency like concat('%', #{insureFeeCurrency}, '%')</if>
<if test="insureFee != null "> and insure_fee = #{insureFee}</if>
<if test="insureRemark != null and insureRemark != ''"> and insure_remark like concat('%', #{insureRemark}, '%')</if>
<if test="insureSiteCode != null and insureSiteCode != ''"> and insure_site_code=#{insureSiteCode}</if>
<if test="blPrint != null and blPrint != ''"> and bl_print=#{blPrint}</if>
<if test="printManCode != null and printManCode != ''"> and print_man_code like concat('%', #{printManCode}, '%')</if>
<if test="printSite != null and printSite != ''"> and print_site=#{printSite},</if>
<if test="printDate != null and printDate != ''"> and print_date like concat('%', #{printDate}, '%')</if>
<if test="blDispFd != null and blDispFd != ''"> and bl_disp_fd=#{blDispFd}</if>
<if test="transferCode != null and transferCode != ''"> and transfer_code like concat('%', #{transferCode}, '%')</if>
<if test="transferBillcode != null and transferBillcode != ''"> and transfer_billcode like concat('%', #{transferBillcode}, '%')</if>
<if test="dispFdDate != null "> and disp_fd_date = #{dispFdDate}</if>
<if test="dispFdReason != null and dispFdReason != ''"> and disp_fd_reason like concat('%', #{dispFdReason}, '%')</if>
<if test="currentSiteCode != null and currentSiteCode != ''"> and current_site_code=#{currentSiteCode}</if>
<if test="nextSiteCode != null and nextSiteCode != ''"> and next_site_code= #{nextSiteCode}</if>
<if test="lastSiteCode != null and lastSiteCode != ''"> and last_site_code=#{lastSiteCode}</if>
<if test="registerSiteCode != null and registerSiteCode != ''"> and register_site_code=#{registerSiteCode}</if>
<if test="registerDate != null "> and register_date = #{registerDate}</if>
<if test="registerManCode != null and registerManCode != ''"> and register_man_code= #{registerManCode}</if>
<if test="takePieceEmployeeCode != null and takePieceEmployeeCode != ''"> and exists (select 1 from sys_user su1, sys_user su2 where su1.emp_code = #{takePieceEmployeeCode} and su2.emp_code = a.take_piece_employee_code and su1.emp_name = su2.emp_name and su1.del_flag='0' and su2.del_flag='0')</if>
<if test="sendDate != null "> and send_date = #{sendDate}</if>
<if test="dispatchManCode != null and dispatchManCode != ''"> and dispatch_man_code=#{dispatchManCode}</if>
<if test="dispatchSiteCode != null and dispatchSiteCode != ''"> and dispatch_site_code=#{dispatchSiteCode}</if>
<if test="produceBillDate != null "> and produce_bill_date = #{produceBillDate}</if>
<if test="produceBillSiteCode != null and produceBillSiteCode != ''"> and produce_bill_site_code=#{produceBillSiteCode}</if>
<if test="produceBillManCode != null and produceBillManCode != ''"> and produce_bill_man_code=#{produceBillManCode}</if>
<if test="destinationCode != null and destinationCode != ''"> and destination_code =#{destinationCode}</if>
<if test="destinationProvince != null and destinationProvince != ''"> and destination_province=#{destinationProvince}</if>
<if test="destinationCity != null and destinationCity != ''"> and destination_city=#{destinationCity}</if>
<if test="destinationCounty != null and destinationCounty != ''"> and destination_county=#{destinationCounty}</if>
<if test="dispatchUnderlingSiteCode != null and dispatchUnderlingSiteCode != ''"> and dispatch_underling_site_code=#{dispatchUnderlingSiteCode}</if>
<if test="destinationCenterCode != null and destinationCenterCode != ''"> and destination_center_code=#{destinationCenterCode}</if>
<if test="marketManCode != null and marketManCode != ''"> and market_man_code = #{marketManCode}</if>
<if test="payee != null and payee != ''"> and a.payee=#{payee}</if>
<if test="salesmen != null and salesmen != ''"> and a.salesmen like concat('%', #{salesmen}, '%')</if>
<if test="operateEmployeeCode != null and operateEmployeeCode != ''"> and operate_employee_code=#{operateEmployeeCode}</if>
<if test="blIsQuestion != null and blIsQuestion != ''"> and bl_is_question=#{blIsQuestion}</if>
<if test="problemType != null and problemType != ''"> and problem_type=#{problemType}</if>
<if test="problemCause != null and problemCause != ''"> and problem_cause like concat('%', #{problemCause}, '%')</if>
<if test="problemDelayDays != null "> and problem_delay_days = #{problemDelayDays}</if>
<if test="blMessage != null and blMessage != ''"> and bl_message=#{blMessage}</if>
<if test="blAcceptMessage != null and blAcceptMessage != ''"> and bl_accept_message=#{blAcceptMessage}</if>
<if test="blGenSubbill != null and blGenSubbill != ''"> and bl_gen_subbill=#{blGenSubbill}</if>
<if test="signMan != null and signMan != ''"> and sign_man like concat('%', #{signMan}, '%')</if>
<if test="signManCode != null and signManCode != ''"> and sign_man_code=#{signManCode}</if>
<if test="signSiteCode != null and signSiteCode != ''"> and sign_site_code=#{signSiteCode}</if>
<if test="paymentStatus != null and paymentStatus != ''"> and FIND_IN_SET(payment_status,#{paymentStatus})</if>
<if test="paymentDate != null "> and payment_date = #{paymentDate}</if>
<if test="paymentRemark != null and paymentRemark != ''"> and payment_remark like concat('%', #{paymentRemark}, '%')</if>
<if test="orderRemark != null and orderRemark != ''"> and order_remark like concat('%', #{orderRemark}, '%')</if>
<if test="sendSiteCode != null and sendSiteCode != ''">and FIND_IN_SET(`send_site_code`,#{sendSiteCode})
</if>
<if test="startSiteCode != null and startSiteCode != ''">
and a.start_site_code=#{startSiteCode}
</if>
<if test="remark != null and remark != ''"> and a.remark like concat('%', #{remark}, '%')</if>
<if test="createBy != null and createBy != ''"> and a.create_by= #{createBy}</if>
<if test="updateBy != null and updateBy != ''"> and a.update_by=#{updateBy}</if>
<if test="createSite != null and createSite != ''"> and a.create_site=#{createSite}</if>
<if test="updateSite != null and updateSite != ''"> and a.update_site=#{updateSite}</if>
<if test="params.problemQueryType != null and params.problemQueryType == 1 and params.problemQueryIds != null and params.problemQueryIds !=''">
and exists (
select 1 from emis_waybill_problem_info ewpi where a.bill_code=ewpi.bill_code and ewpi.del_flag='0' and FIND_IN_SET( ewpi.`problem_type`, #{params.problemQueryIds} )
)
</if>
<if test="params.problemQueryType != null and params.problemQueryType == 2 and params.problemQueryIds != null and params.problemQueryIds !=''">
and not exists (
select 1 from emis_waybill_problem_info ewpi where a.bill_code=ewpi.bill_code and ewpi.del_flag='0' and FIND_IN_SET( ewpi.`problem_type`, #{params.problemQueryIds} )
)
</if>
<if test="params.waybillStatType != null and params.waybillStatType == 1">
and a.order_type='0'
and a.waybill_status='0'
and a.order_status in('0','3')
and (
a.take_piece_employee_code=#{params.privEmpCode}
or (a.pickup_method in('1','3') and a.operate_employee_code is null )
or (a.operate_employee_code=#{params.privEmpCode} )
)
</if>
<if test="params.waybillStatType != null and params.waybillStatType == 2">
and a.waybill_status!='0' and a.order_status!='2'
and (
a.operate_employee_code=#{params.privEmpCode}
or a.take_piece_employee_code=#{params.privEmpCode}
or a.register_man_code=#{params.privEmpCode}
)
</if>
<if test="params.waybillStatType != null and params.waybillStatType == 3">
and a.order_status='2'
and (
a.operate_employee_code=#{params.privEmpCode}
or a.take_piece_employee_code=#{params.privEmpCode}
)
</if>
<!-- 转单 -->
<if test="params.waybillStatType != null and params.waybillStatType == 4">
and a.order_status in('0','3') and exists (
select 1 from emis_waybill_change_to ewcto where a.bill_code=ewcto.bill_code and ewcto.change_from=#{params.privEmpCode}
)
</if>
<if test="params.beginOrderDate != null and params.beginOrderDate != ''">
and a.order_date <![CDATA[ >= ]]> #{params.beginOrderDate}
</if>
<if test="params.endOrderDate != null and params.endOrderDate != ''">
and a.order_date <![CDATA[ <= ]]> #{params.endOrderDate}
</if>
<if test="payee != null and payee != ''">
and a.payee=#{payee}
</if>
<if test="salesmen != null and salesmen != '' " >
and a.salesmen=#{salesmen}
</if>
<if test="blSign != null and blSign != ''">
and a.bl_sign=#{blSign}
</if>
<if test="params.beginDate != null and params.beginDate != ''">
and a.send_date <![CDATA[ >= ]]> #{params.beginDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and a.send_date <![CDATA[ <= ]]> #{params.endDate}
</if>
<if test="params.blUploadGoodsPic != null and params.blUploadGoodsPic != '' and params.blUploadGoodsPic == 1">
and a.goods_pics is not null
</if>
<if test="params.blUploadGoodsPic != null and params.blUploadGoodsPic != '' and params.blUploadGoodsPic == 0">
and a.goods_pics is null
</if>
<if test="params.beginSendDate != null and params.beginSendDate != ''">
and a.send_date <![CDATA[ >= ]]> #{params.beginSendDate}
</if>
<if test="params.endSendDate != null and params.endSendDate != ''">
and a.send_date <![CDATA[ <= ]]> #{params.endSendDate}
</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != ''">
and a.create_time <![CDATA[ >= ]]> #{params.beginCreateTime}
</if>
<if test="params.endCreateTime != null and params.endCreateTime != ''">
and a.create_time <![CDATA[ <= ]]> #{params.endCreateTime}
</if>
<if test="params.expireNotSign != null and params.expireNotSign == 1">
and a.estimate_date <![CDATA[ < ]]> now() and bl_sign!='1'
</if>
<if test="params.printFlag != null ">
and a.bl_print=#{params.printFlag}
</if>
<if test="params.isNeedPack != null and params.isNeedPack == 1">
and not EXISTS ( select 1 from emis_tms_pack_dtl etp where etp.del_flag='0' and etp.main_bill_code=a.bill_code )
and a.trans_line_type in(
select line_code from emis_trans_line etl where etl.trans_type=1
)
and bl_sign!='1' and waybill_status!='40'
and (a.send_site_code=#{params.privSiteCode} or a.start_site_code=#{params.privSiteCode})
and a.current_site_code=#{params.privSiteCode}
</if>
<if test="params.isNeedBatch != null and params.isNeedBatch == 1">
and a.bill_code = #{billCode}
<!--
and a.bill_code not in(
select etsbd.bill_code from emis_tms_site_batch_dtl etsbd,emis_tms_site_batch etsb
where etsbd.batch_no=etsb.batch_no and etsbd.del_flag='0' and etsb.del_flag='0' and etsb.batch_type=#{params.batchType}
)
-->
</if>
<!-- 查询现金客户额度属性; 1:查询超期额度,2:查询账期内额度 -->
<if test="params.queryQuotaType != null and params.queryQuotaType == 1">
and a.send_date is not null
and DATEDIFF(NOW(), a.send_date) > 10
</if>
<if test="params.queryQuotaType != null and params.queryQuotaType == 2">
and a.send_date is not null
and DATEDIFF(NOW(), a.send_date) <![CDATA[ <= ]]> 10
</if>
<if test="(params.isNeedBatch == null or (params.isNeedBatch != null and params.isNeedBatch != 1) ) " >
<if test="(salesmen == null or salesmen=='') and params.privSiteCode != null and params.privSiteCode != '88888'">
and (
a.send_site_code=#{params.privSiteCode}
or a.dispatch_site_code=#{params.privSiteCode}
or a.start_site_code=#{params.privSiteCode}
<if test="params.isQueryPrintOrder != null and params.isQueryPrintOrder == 1">
or EXISTS (select 1 from emis_tms_scan_record etsr where a.bill_code=etsr.main_bill_code and etsr.scan_site_code=#{params.privSiteCode})
</if>
<if test="custNo != null and custNo != ''">
or EXISTS (
select 1 from emis_customer_user ecu where a.cust_no=ecu.monthly_pay_code and ecu.owner_site=#{params.privSiteCode}
)
</if>
or a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.salesmen in(
select salesmen from emis_salesmen_rel esr where esr.del_flag='0' and esr.bl_open='1' and now() <![CDATA[ >= ]]> esr.start_date and now() <![CDATA[ <= ]]> esr.end_date and esr.sales_ass=#{params.privEmpName}
)
or a.operate_employee_code=#{params.privEmpCode}
or a.take_piece_employee_code=#{params.privEmpCode}
)
</if>
</if>
</where>
</select>
<select id="selectLatestMonthCreateOrderMapList" parameterType="EmisWaybill" resultType="map">
SELECT
DATE_FORMAT( create_time, '%Y-%m-%d' ) AS createDay,
@ -2085,6 +2435,8 @@
ifnull(round(sum(settlement_weight),2),0) as totalSettlementWeight,
ifnull(round(sum(freight),2),0) as totalFreight
from emis_waybill a
left join emis_customer_user a4 on a.cust_no = a4.monthly_pay_code and a4.del_flag = '0'
left join emis_waybill_other wss on a.id = wss.waybill_id and wss.del_flag = '0'
<where>
a.del_flag='0' and a.order_status !='0' and a.order_status!='2'
<if test="id != null "> and a.id = #{id}</if>
@ -2112,6 +2464,7 @@
<if test="customerCode != null and customerCode != ''"> and customer_code=#{customerCode}</if>
<if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
<if test="openId != null and openId != ''"> and open_id like concat('%', #{openId}, '%')</if>
<include refid="salesSupportFilter"/>
<if test="receiveName != null and receiveName != ''"> and receive_name like concat('%', #{receiveName}, '%')</if>
<if test="receiveCompany != null and receiveCompany != ''"> and receive_company like concat('%', #{receiveCompany}, '%')</if>
<if test="receiveMobile != null and receiveMobile != ''"> and receive_mobile like concat('%', #{receiveMobile}, '%')</if>
@ -4278,10 +4631,6 @@
<if test="salesExecutive != null and salesExecutive != ''">
AND a4.sales_executive LIKE CONCAT('%', #{salesExecutive}, '%')
</if>
<!-- 销售支持 -->
<if test="salesSupport != null and salesSupport != ''">
AND a4.sales_support LIKE CONCAT('%', #{salesSupport}, '%')
</if>
<!-- 销售联系人 -->
<if test="salesmen != null and salesmen != ''">
AND a4.salesmen LIKE CONCAT('%', #{salesmen}, '%')