md
This commit is contained in:
parent
5aef70e088
commit
c7105c2229
@ -12,6 +12,7 @@ package com.xdadan.erp.emis.service.impl;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
@ -74,12 +75,16 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
|||||||
@Async
|
@Async
|
||||||
@Override
|
@Override
|
||||||
public void autoDoProfit() {
|
public void autoDoProfit() {
|
||||||
|
|
||||||
|
Map<String,Map<String,String> > profitMap = new HashMap<>();
|
||||||
// 获取需要出账的运单列表
|
// 获取需要出账的运单列表
|
||||||
EmisWaybill qEmisWaybill = new EmisWaybill();
|
EmisWaybill qEmisWaybill = new EmisWaybill();
|
||||||
List<EmisWaybill> list = emisWaybillMapper.selectWaitDoProfitList(qEmisWaybill);
|
List<EmisWaybill> list = emisWaybillMapper.selectWaitDoProfitList(qEmisWaybill);
|
||||||
|
|
||||||
// 多线程并发处理
|
// 多线程并发处理
|
||||||
if(!CollectionUtil.isEmpty(list)){
|
if(!CollectionUtil.isEmpty(list)){
|
||||||
|
|
||||||
|
|
||||||
List<List<EmisWaybill> > mutiOrderList = ListUtils.partition(list, 100);
|
List<List<EmisWaybill> > mutiOrderList = ListUtils.partition(list, 100);
|
||||||
int realGroupSize=mutiOrderList.size();
|
int realGroupSize=mutiOrderList.size();
|
||||||
|
|
||||||
@ -99,6 +104,10 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
latch.await(300, TimeUnit.SECONDS);
|
latch.await(300, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
// 线程结束后计算所有员工提成
|
||||||
|
reCalcEmpProfitSumMoney(null,null);
|
||||||
|
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}finally {
|
}finally {
|
||||||
@ -163,7 +172,6 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void reCalcProfitByBillCode(String billCode)
|
public void reCalcProfitByBillCode(String billCode)
|
||||||
{
|
{
|
||||||
|
|
||||||
String lockKey="reCalcProfitByBillCode"+billCode;
|
String lockKey="reCalcProfitByBillCode"+billCode;
|
||||||
// 加锁查询
|
// 加锁查询
|
||||||
log.error("reCalcProfitByBillCode start:"+billCode);
|
log.error("reCalcProfitByBillCode start:"+billCode);
|
||||||
@ -221,7 +229,6 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
|||||||
else if (postTypeIndex == ProfitPostType.DZ_EMP.typeCode) {
|
else if (postTypeIndex == ProfitPostType.DZ_EMP.typeCode) {
|
||||||
calcDzProfit(waybill);
|
calcDzProfit(waybill);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 运单打上已计算提成标记
|
// 运单打上已计算提成标记
|
||||||
@ -236,19 +243,30 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int reCalcEmpProfitSumMoney(String empName,String billMonth){
|
private int reCalcEmpProfitSumMoney(String empName,String billMonth){
|
||||||
// 获取统计数据
|
String lockKey="reCalcEmpProfitSumMoney_"+empName+billMonth;
|
||||||
List<EmisCommissionProfit> listProfit=emisCommissionProfitMapper.selectProfitStatList(empName,billMonth);
|
// 加锁查询
|
||||||
for (EmisCommissionProfit profitItem:listProfit) {
|
log.error("reCalcEmpProfitSumMoney start:"+empName+billMonth);
|
||||||
// 查询是否有数据,没有则插入
|
redissonService.lock(lockKey, 300);
|
||||||
int isExists=emisCommissionProfitMapper.checkUnique(profitItem);
|
try {
|
||||||
if(isExists==1){
|
// 获取统计数据
|
||||||
emisCommissionProfitMapper.updateProfitMoney(profitItem);
|
List<EmisCommissionProfit> listProfit=emisCommissionProfitMapper.selectProfitStatList(empName,billMonth);
|
||||||
}else{
|
for (EmisCommissionProfit profitItem:listProfit) {
|
||||||
String profitNo=WaybillHelper.genProfitNo();
|
// 查询是否有数据,没有则插入
|
||||||
profitItem.setProfitNo(profitNo);
|
int isExists=emisCommissionProfitMapper.checkUnique(profitItem);
|
||||||
emisCommissionProfitMapper.insertEmisCommissionProfit(profitItem);
|
if(isExists==1){
|
||||||
|
emisCommissionProfitMapper.updateProfitMoney(profitItem);
|
||||||
|
}else{
|
||||||
|
String profitNo=WaybillHelper.genProfitNo();
|
||||||
|
profitItem.setProfitNo(profitNo);
|
||||||
|
emisCommissionProfitMapper.insertEmisCommissionProfit(profitItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}catch (Exception ex){
|
||||||
|
redissonService.unlock(lockKey);
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
redissonService.unlock(lockKey);
|
||||||
|
log.error("reCalcProfitByBillCode end:"+empName+billMonth);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,11 +32,13 @@
|
|||||||
<select id="selectProfitStatList" parameterType="String" resultMap="EmisCommissionProfitResult">
|
<select id="selectProfitStatList" parameterType="String" resultMap="EmisCommissionProfitResult">
|
||||||
select emp_name ,bill_month, sum(money) as money
|
select emp_name ,bill_month, sum(money) as money
|
||||||
from emis_commission_dtl a
|
from emis_commission_dtl a
|
||||||
where a.emp_name = #{empName}
|
where del_flag='0'
|
||||||
|
<if test="empName != null and empName != ''">
|
||||||
|
a.emp_name = #{empName}
|
||||||
|
</if>
|
||||||
<if test="billMonth != null and billMonth != ''">
|
<if test="billMonth != null and billMonth != ''">
|
||||||
and bill_month=#{billMonth}
|
and bill_month=#{billMonth}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
group by emp_name,bill_month
|
group by emp_name,bill_month
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user