|
|
|
@@ -6,7 +6,11 @@ import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; |
|
|
|
import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl; |
|
|
|
import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; |
|
|
|
import com.iformall.domain.po.MallUserInfo; |
|
|
|
import com.iformall.domain.po.WxShop; |
|
|
|
import com.iformall.domain.vo.WxBillDailyVo; |
|
|
|
import com.iformall.enums.EnumDelStatus; |
|
|
|
import com.iformall.enums.EnumShopStatus; |
|
|
|
import com.iformall.mapper.WxShopMapper; |
|
|
|
import com.iformall.service.WxBillDailyService; |
|
|
|
import org.apache.shiro.session.UnknownSessionException; |
|
|
|
import org.slf4j.Logger; |
|
|
|
@@ -17,6 +21,8 @@ import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
@@ -30,6 +36,9 @@ public class BillDailyAsyncTask { |
|
|
|
@Autowired |
|
|
|
StringRedisTemplate stringRedisTemplate; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxShopMapper wxShopMapper; |
|
|
|
|
|
|
|
private class BillDailyExcelHandler extends ExcelDataHandlerDefaultImpl<WxBillDailyVo> { |
|
|
|
@Override |
|
|
|
public Object importHandler(WxBillDailyVo obj, String name, Object value) { |
|
|
|
@@ -56,9 +65,9 @@ public class BillDailyAsyncTask { |
|
|
|
public void importExcelData(File file, MallUserInfo user, String importKey, String tenantId) { |
|
|
|
ImportParams params = new ImportParams(); |
|
|
|
// 需要验证 |
|
|
|
params.setImportFields(new String[]{"商铺号", "费用类型", "实际应收金额", "实收金额", "截止收款日期", "逾期天数"}); |
|
|
|
params.setImportFields(new String[]{"商铺号", "费用类型", "实际应收金额(元)", "实收金额(元)", "缴款截止日期", "逾期天数"}); |
|
|
|
IExcelDataHandler<WxBillDailyVo> handler = new BillDailyAsyncTask.BillDailyExcelHandler(); |
|
|
|
handler.setNeedHandlerFields(new String[]{"商铺号", "费用类型", "实际应收金额", "实收金额", "截止收款日期", "逾期天数"}); |
|
|
|
handler.setNeedHandlerFields(new String[]{"商铺号", "费用类型", "实际应收金额(元)", "实收金额(元)", "缴款截止日期", "逾期天数"}); |
|
|
|
params.setNeedVerify(true); |
|
|
|
|
|
|
|
ExcelImportResult<WxBillDailyVo> datalist = null; |
|
|
|
@@ -83,23 +92,67 @@ public class BillDailyAsyncTask { |
|
|
|
|
|
|
|
List<WxBillDailyVo> successList = datalist.getList(); |
|
|
|
List<WxBillDailyVo> failList = datalist.getFailList(); |
|
|
|
List<WxBillDailyVo> processList = new ArrayList<>(); |
|
|
|
|
|
|
|
int fail = 0; |
|
|
|
for (WxBillDailyVo vo : successList) { |
|
|
|
|
|
|
|
//店铺 |
|
|
|
WxShop shop = new WxShop(); |
|
|
|
shop.setShopNumber(vo.getShopNumber()); |
|
|
|
shop.setTenantId(tenantId); |
|
|
|
shop.setStatus(EnumShopStatus.RENT.getCode()); |
|
|
|
shop.setIsDel(EnumDelStatus.NOT_DEL.getCode()); |
|
|
|
WxShop wxShop = wxShopMapper.selectOne(shop); |
|
|
|
if (wxShop == null) { |
|
|
|
logger.error("店铺不存在", vo.toString()); |
|
|
|
fail++; |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("验证通过的数量: " + successList.size()); |
|
|
|
String receivePayStr = vo.getReceivePayStr(); |
|
|
|
double receivePayD = new BigDecimal(receivePayStr).doubleValue(); |
|
|
|
if (receivePayD <= 0) { |
|
|
|
logger.error("实际应收金额小于等于0", vo.toString()); |
|
|
|
fail++; |
|
|
|
continue; |
|
|
|
} |
|
|
|
String payStr = vo.getPayStr(); |
|
|
|
double payD = new BigDecimal(payStr).doubleValue(); |
|
|
|
if (payD < 0) { |
|
|
|
logger.error("实收金额小于0", vo.toString()); |
|
|
|
fail++; |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (receivePayD < payD) { |
|
|
|
logger.error("实际应收金额小于实收金额", vo.toString()); |
|
|
|
fail++; |
|
|
|
continue; |
|
|
|
} |
|
|
|
long receivePay = new BigDecimal(receivePayD).multiply(new BigDecimal(100)).longValue(); |
|
|
|
vo.setReceivePay(receivePay); |
|
|
|
long pay = new BigDecimal(payD).multiply(new BigDecimal(100)).longValue(); |
|
|
|
vo.setPay(pay); |
|
|
|
vo.setTenantId(tenantId); |
|
|
|
vo.setShopId(wxShop.getId()); |
|
|
|
vo.setRentShopType(wxShop.getType()); |
|
|
|
processList.add(vo); |
|
|
|
} |
|
|
|
logger.info("验证通过的数量: " + processList.size()); |
|
|
|
logger.info("验证未通过的数量: " + failList.size()); |
|
|
|
|
|
|
|
int total = successList.size() + failList.size(); |
|
|
|
int all_success = successList.size(); |
|
|
|
int all_fail = failList.size(); |
|
|
|
int all_success = processList.size(); |
|
|
|
int all_fail = failList.size() + fail; |
|
|
|
int total = processList.size() + all_fail; |
|
|
|
|
|
|
|
//添加到redis里 |
|
|
|
set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); |
|
|
|
|
|
|
|
if (successList.size() > 0) { |
|
|
|
if (processList.size() > 0) { |
|
|
|
try { |
|
|
|
successList.parallelStream().forEach(billDaily -> { |
|
|
|
processList.parallelStream().forEach(billDaily -> { |
|
|
|
try { |
|
|
|
//插入数据 |
|
|
|
billDaily.setTenantId(tenantId); |
|
|
|
wxBillDailyService.insertData(billDaily, importKey, user); |
|
|
|
} catch (UnknownSessionException ue) { |
|
|
|
logger.error("session :" + ue.getMessage()); |
|
|
|
|