|
@@ -2,12 +2,11 @@ package com.rongwei.zhsw.system.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.rongwe.zhsw.system.domain.SwBillManagementUnpaidDo;
|
|
|
-import com.rongwe.zhsw.system.domain.SwEnterpriseConfigInfoDo;
|
|
|
import com.rongwe.zhsw.system.domain.SwUserManagementDo;
|
|
|
import com.rongwe.zhsw.system.domain.SwWaterUsageEntryDo;
|
|
|
+import com.rongwei.commonservice.service.RedisService;
|
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
|
-import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
import com.rongwei.rwcommon.utils.Constants;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.zhsw.system.utils.ZHSWCommonUtils;
|
|
@@ -27,11 +26,9 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.time.LocalDate;
|
|
|
import java.time.YearMonth;
|
|
|
import java.time.ZoneId;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
-import java.time.temporal.TemporalAccessor;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -55,7 +52,8 @@ public class BillGenerationServiceImpl {
|
|
|
private DataSourceTransactionManager transactionManager;
|
|
|
@Autowired
|
|
|
private SwEnterpriseConfigInfoServiceImpl swEnterpriseConfigInfoService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private RedisService redisService;
|
|
|
private static final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
public static String formatDate(Date date) {
|
|
@@ -66,17 +64,20 @@ public class BillGenerationServiceImpl {
|
|
|
|
|
|
/**
|
|
|
* 异步方法
|
|
|
+ *
|
|
|
* @param swWaterUsageEntryDoList
|
|
|
* @param attributes
|
|
|
*/
|
|
|
@Async(value = "zhswThreadPool")
|
|
|
- public void asyncGenerateBill(List<SwWaterUsageEntryDo> swWaterUsageEntryDoList, HttpServletRequest httpServletRequest){
|
|
|
+ public void asyncGenerateBill(List<SwWaterUsageEntryDo> swWaterUsageEntryDoList, HttpServletRequest httpServletRequest, String dskey) {
|
|
|
if (swWaterUsageEntryDoList == null || swWaterUsageEntryDoList.isEmpty()) {
|
|
|
log.error("暂无需要生成账单的信息");
|
|
|
return;
|
|
|
}
|
|
|
- SysUserVo currentUser = ZHSWCommonUtils.getCurrentUser();
|
|
|
- String dskey = currentUser.getTenantDo().getDskey();
|
|
|
+ if(httpServletRequest==null){
|
|
|
+ httpServletRequest =((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
+ }
|
|
|
+ log.info("httpServletRequest是否为空:{},所属库名:{}", httpServletRequest == null, dskey);
|
|
|
httpServletRequest.setAttribute(Constants.SAAS_LOGIN_TOKEN, dskey);
|
|
|
generateBill(swWaterUsageEntryDoList);
|
|
|
}
|
|
@@ -189,8 +190,13 @@ public class BillGenerationServiceImpl {
|
|
|
log.error("抄表记录ID为空");
|
|
|
return;
|
|
|
}
|
|
|
+ String token = httpServletRequest.getHeader("token");
|
|
|
+ log.info("token:{}", token);
|
|
|
+ SysUserVo loginUser = redisService.getLoginUser(token);
|
|
|
+ log.info("获取到的用户信息为:{}", loginUser);
|
|
|
+ String dskey = loginUser.getTenantDo().getDskey();
|
|
|
log.info("开始给抄表记录:{},生成账单信息", ids);
|
|
|
- this.asyncGenerateBill(swWaterUsageEntryService.getBaseMapper().selectBatchIds(ids), httpServletRequest);
|
|
|
+ this.asyncGenerateBill(swWaterUsageEntryService.getBaseMapper().selectBatchIds(ids), httpServletRequest, dskey);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -199,7 +205,9 @@ public class BillGenerationServiceImpl {
|
|
|
.eq(SwWaterUsageEntryDo::getDeleted, "0")
|
|
|
.eq(SwWaterUsageEntryDo::getState, 0));
|
|
|
log.info("开始给抄表记录:{},生成账单信息", list.stream().map(SwWaterUsageEntryDo::getId).collect(Collectors.toList()));
|
|
|
- this.asyncGenerateBill(list, request);
|
|
|
+ SysUserVo currentUser = ZHSWCommonUtils.getCurrentUser();
|
|
|
+ String dskey = currentUser.getTenantDo().getDskey();
|
|
|
+ this.asyncGenerateBill(list, request, dskey);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -334,5 +342,4 @@ public class BillGenerationServiceImpl {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|