md
This commit is contained in:
parent
175dcd8271
commit
e2baa7ee32
@ -13,6 +13,9 @@ package com.xdadan.erp.emis.service.impl;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -30,6 +33,7 @@ import com.xdadan.erp.emis.mapper.EmisWaybillMapper;
|
||||
import com.xdadan.erp.emis.service.EmisBaseService;
|
||||
import com.xdadan.erp.emis.utils.WaybillHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@ -73,15 +77,79 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
||||
// 获取需要出账的运单列表
|
||||
EmisWaybill qEmisWaybill = new EmisWaybill();
|
||||
List<EmisWaybill> list = emisWaybillMapper.selectWaitDoProfitList(qEmisWaybill);
|
||||
|
||||
// 多线程并发处理
|
||||
if(!CollectionUtil.isEmpty(list)){
|
||||
for(EmisWaybill dt:list){
|
||||
List<List<EmisWaybill> > mutiOrderList = ListUtils.partition(list, 100);
|
||||
int realGroupSize=mutiOrderList.size();
|
||||
|
||||
// 计数处理
|
||||
CountDownLatch latch = new CountDownLatch(realGroupSize);
|
||||
//多线程运行
|
||||
long startTime=System.currentTimeMillis();
|
||||
|
||||
for(int i=0; i<realGroupSize;i++){
|
||||
Runnable doRunnable=new EmisCommissionProfitServiceImpl.MultiDoThread(
|
||||
mutiOrderList.get(i),
|
||||
latch,
|
||||
"MultiDoThread==>"+i);
|
||||
Thread doThread = new Thread(doRunnable, " Profit MultiDoThread-"+i);
|
||||
doThread.start();
|
||||
}
|
||||
|
||||
try {
|
||||
latch.await(300, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
}
|
||||
long endTime=System.currentTimeMillis(); //获取结束时间
|
||||
log.info("Profit MultiDoThread End escape time: "+(endTime-startTime)+"ms");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 多线程处理
|
||||
class MultiDoThread implements Runnable {
|
||||
private List<EmisWaybill> dataList = null;
|
||||
private CountDownLatch latch = null;
|
||||
|
||||
public MultiDoThread(
|
||||
List<EmisWaybill> dataList,
|
||||
CountDownLatch latch ,
|
||||
String name
|
||||
){
|
||||
this.dataList = dataList;
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
private void doData(){
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
for (EmisWaybill waybill : dataList) {
|
||||
try {
|
||||
reCalcProfitByBillCode(dt.getBillCode());
|
||||
reCalcProfitByBillCode(waybill.getBillCode());
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
long end4 = System.currentTimeMillis();
|
||||
log.info(name+" escape time xxxx666:" + (end4 - start) + "ms");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
log.debug(name+":Do profit thread start!");
|
||||
try {
|
||||
doData();
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
latch.countDown();
|
||||
log.debug(name+":Do profit thread thread end!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -394,7 +462,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
||||
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
|
||||
|
||||
// 单独根据人名称和月份汇总统计
|
||||
reCalcEmpProfitSumMoney(empUser.getEmpName(),billMonth);
|
||||
// reCalcEmpProfitSumMoney(empUser.getEmpName(),billMonth);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -504,7 +572,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
||||
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
|
||||
|
||||
// 单独根据人名称和月份汇总统计
|
||||
reCalcEmpProfitSumMoney(empUser.getEmpName(),billMonth);
|
||||
// reCalcEmpProfitSumMoney(empUser.getEmpName(),billMonth);
|
||||
|
||||
}else{
|
||||
log.error("计算提成费用为0");
|
||||
@ -620,7 +688,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
||||
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
|
||||
|
||||
// 单独根据人名称和月份汇总统计
|
||||
reCalcEmpProfitSumMoney(empUser.getEmpName(),billMonth);
|
||||
// reCalcEmpProfitSumMoney(empUser.getEmpName(),billMonth);
|
||||
|
||||
}else{
|
||||
log.error("计算提成费用为0");
|
||||
@ -733,7 +801,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
||||
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
|
||||
|
||||
// 单独根据人名称和月份汇总统计
|
||||
reCalcEmpProfitSumMoney(empUser.getEmpName(),billMonth);
|
||||
// reCalcEmpProfitSumMoney(empUser.getEmpName(),billMonth);
|
||||
}else{
|
||||
log.error("计算提成费用为0");
|
||||
}
|
||||
@ -982,7 +1050,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
||||
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
|
||||
|
||||
// 单独根据人名称和月份汇总统计
|
||||
reCalcEmpProfitSumMoney(empUser.getEmpName(),billMonth);
|
||||
// reCalcEmpProfitSumMoney(empUser.getEmpName(),billMonth);
|
||||
}
|
||||
}else{
|
||||
log.error("计算提成费用为0");
|
||||
@ -1097,7 +1165,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
||||
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
|
||||
|
||||
// 单独根据人名称和月份汇总统计
|
||||
reCalcEmpProfitSumMoney(empUser.getEmpName(),billMonth);
|
||||
// reCalcEmpProfitSumMoney(empUser.getEmpName(),billMonth);
|
||||
}
|
||||
}else{
|
||||
log.error("计算提成费用为0");
|
||||
@ -1115,8 +1183,6 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询员工提成表
|
||||
*
|
||||
|
||||
@ -1960,70 +1960,32 @@
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 通用权限判断 参数 isPrivQuery -->
|
||||
<!-- 查询待出账运单 -->
|
||||
<select id="selectWaitDoBillList" parameterType="EmisWaybill" resultMap="EmisWaybillResult">
|
||||
select
|
||||
id, order_sn, cust_order_id, bill_code, order_status, waybill_status, order_type,
|
||||
order_date, user_id, customer_code, customer_name, open_id, receive_name, receive_company, receive_mobile,
|
||||
receive_tel, receive_country, receive_province, receive_city, receive_county, receive_town,
|
||||
receive_address, receive_postcode, receive_pcd, send_name, send_company, send_mobile, send_tel,
|
||||
send_country, send_province, send_city, send_county, send_town, send_address, send_postcode,
|
||||
send_pcd, payment_type, calc_fee_type, cust_no, cust_name, trans_line_type, product_type, time_type,
|
||||
meter_type, carry_type, customs_clear, customs_eclaration, estimate_date, pack_type, dispatch_method,
|
||||
pickup_method, pick_start_date, pick_finish_date, pick_fail_reason, into_warehouse_code, into_warehouse_name,
|
||||
into_warehouse_address, into_warehouse_contact, into_warehouse_phone, into_warehouse_bill_code, warehouse_in_no,
|
||||
customer_delivery_begin_time, customer_delivery_end_time, goods_type, goods_info, goods_pics, bl_prepare_in_freight,
|
||||
prepare_in_est_fee, prepare_in_real_fee, prepare_in_express, prepare_in_bill_code, prepare_in_remark,
|
||||
prepare_in_supplier, total_weight, total_volume, parcel_qty, bill_weight, volume_weight, currency,
|
||||
settlement_weight, scan_weight, fee_weight, freight, real_payment_type, real_fee, bl_special_quote, bl_over_long,
|
||||
bl_bill, bl_bill_text, bl_over_weight, over_weight_number, fee_remark, third_code, real_value, bl_insure,
|
||||
insure_value, insure_value_currency, insure_fee_currency, insure_fee, insure_remark, insure_site_code,
|
||||
insure_date, bl_print, print_man_code, print_site, print_date, print_count, bl_disp_fd, transfer_code,
|
||||
transfer_billcode, disp_fd_date, disp_fd_reason, current_site_code, next_site_code, last_site_code,
|
||||
register_site_code, register_date, register_man_code, take_piece_employee_code, send_site_code,
|
||||
send_center_code, send_date, dispatch_man_code, dispatch_date, dispatch_site_code, produce_bill_date,
|
||||
produce_bill_site_code, produce_bill_man_code, destination_code, destination_province, destination_city,
|
||||
destination_county, dispatch_underling_site_code, destination_center_code, market_man_code, payee,
|
||||
salesmen, operate_employee_code, bl_is_question, problem_type, problem_cause, problem_delay_days,
|
||||
bl_message, bl_accept_message, bl_gen_subbill, bl_sign, sign_man, sign_man_code, sign_site_code,
|
||||
sign_date, bill_pic_send_rmk, bill_pic_dispatch_rmk, timezone_offset, payment_status, payment_date,
|
||||
payment_remark, order_remark, data_from, bl_special_goods, remark, del_flag, create_by, create_time,
|
||||
update_by, update_time, create_site, update_site,ext_info
|
||||
from emis_waybill a
|
||||
where a.del_flag='0' and a.bl_bill = '0' and a.order_status !='0' and a.order_status!='2' limit 300
|
||||
select bill_code from emis_waybill a
|
||||
where
|
||||
a.del_flag='0' and a.bl_bill = '0' and a.order_status !='0'
|
||||
and a.order_status!='2' and waybill_status != '0'
|
||||
and ( a.problem_type is null or (a.problem_type is not null and (a.problem_type != 173 and a.problem_type != 170 and a.problem_type != 151) ) )
|
||||
|
||||
limit 300
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 查询待提成运单 -->
|
||||
<select id="selectWaitDoProfitList" parameterType="EmisWaybill" resultMap="EmisWaybillResult">
|
||||
select
|
||||
id, order_sn, cust_order_id, bill_code, order_status, waybill_status, order_type,
|
||||
order_date, user_id, customer_code, customer_name, open_id, receive_name, receive_company, receive_mobile,
|
||||
receive_tel, receive_country, receive_province, receive_city, receive_county, receive_town,
|
||||
receive_address, receive_postcode, receive_pcd, send_name, send_company, send_mobile, send_tel,
|
||||
send_country, send_province, send_city, send_county, send_town, send_address, send_postcode,
|
||||
send_pcd, payment_type, calc_fee_type, cust_no, cust_name, trans_line_type, product_type, time_type,
|
||||
meter_type, carry_type, customs_clear, customs_eclaration, estimate_date, pack_type, dispatch_method,
|
||||
pickup_method, pick_start_date, pick_finish_date, pick_fail_reason, into_warehouse_code, into_warehouse_name,
|
||||
into_warehouse_address, into_warehouse_contact, into_warehouse_phone, into_warehouse_bill_code, warehouse_in_no,
|
||||
customer_delivery_begin_time, customer_delivery_end_time, goods_type, goods_info, goods_pics, bl_prepare_in_freight,
|
||||
prepare_in_est_fee, prepare_in_real_fee, prepare_in_express, prepare_in_bill_code, prepare_in_remark,
|
||||
prepare_in_supplier, total_weight, total_volume, parcel_qty, bill_weight, volume_weight, currency,
|
||||
settlement_weight, scan_weight, fee_weight, freight, real_payment_type, real_fee, bl_special_quote, bl_over_long,
|
||||
bl_bill, bl_bill_text, bl_over_weight, over_weight_number, fee_remark, third_code, real_value, bl_insure,
|
||||
insure_value, insure_value_currency, insure_fee_currency, insure_fee, insure_remark, insure_site_code,
|
||||
insure_date, bl_print, print_man_code, print_site, print_date, print_count, bl_disp_fd, transfer_code,
|
||||
transfer_billcode, disp_fd_date, disp_fd_reason, current_site_code, next_site_code, last_site_code,
|
||||
register_site_code, register_date, register_man_code, take_piece_employee_code, send_site_code,
|
||||
send_center_code, send_date, dispatch_man_code, dispatch_date, dispatch_site_code, produce_bill_date,
|
||||
produce_bill_site_code, produce_bill_man_code, destination_code, destination_province, destination_city,
|
||||
destination_county, dispatch_underling_site_code, destination_center_code, market_man_code, payee,
|
||||
salesmen, operate_employee_code, bl_is_question, problem_type, problem_cause, problem_delay_days,
|
||||
bl_message, bl_accept_message, bl_gen_subbill, bl_sign, sign_man, sign_man_code, sign_site_code,
|
||||
sign_date, bill_pic_send_rmk, bill_pic_dispatch_rmk, timezone_offset, payment_status, payment_date,
|
||||
payment_remark, order_remark, data_from, bl_special_goods, remark, del_flag, create_by, create_time,
|
||||
update_by, update_time, create_site, update_site,ext_info
|
||||
from emis_waybill a
|
||||
where a.del_flag='0' and a.bl_profit = '0' and a.order_status !='0' and a.order_status!='2' order by a.send_date desc limit 300
|
||||
SELECT
|
||||
bill_code
|
||||
FROM
|
||||
emis_waybill a
|
||||
WHERE
|
||||
a.del_flag = '0'
|
||||
AND a.bl_profit = '0'
|
||||
AND a.order_status != '0'
|
||||
AND a.order_status != '2'
|
||||
AND ( a.problem_type is null or (a.problem_type is not null and (a.problem_type != 173 and a.problem_type != 170 and a.problem_type != 151) ) )
|
||||
|
||||
ORDER BY a.send_date DESC
|
||||
LIMIT 1000
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user