|
@@ -2,10 +2,13 @@ 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.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;
|
|
|
import org.slf4j.Logger;
|
|
@@ -20,6 +23,7 @@ import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -49,6 +53,8 @@ public class BillGenerationServiceImpl {
|
|
|
private SwBillManagementUnpaidServiceImpl swBillManagementUnpaidService;
|
|
|
@Autowired
|
|
|
private DataSourceTransactionManager transactionManager;
|
|
|
+ @Autowired
|
|
|
+ private SwEnterpriseConfigInfoServiceImpl swEnterpriseConfigInfoService;
|
|
|
|
|
|
private static final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
@@ -64,12 +70,14 @@ public class BillGenerationServiceImpl {
|
|
|
* @param attributes
|
|
|
*/
|
|
|
@Async(value = "zhswThreadPool")
|
|
|
- public void asyncGenerateBill(List<SwWaterUsageEntryDo> swWaterUsageEntryDoList, ServletRequestAttributes attributes){
|
|
|
- RequestContextHolder.setRequestAttributes(attributes);
|
|
|
+ public void asyncGenerateBill(List<SwWaterUsageEntryDo> swWaterUsageEntryDoList, HttpServletRequest httpServletRequest){
|
|
|
if (swWaterUsageEntryDoList == null || swWaterUsageEntryDoList.isEmpty()) {
|
|
|
log.error("暂无需要生成账单的信息");
|
|
|
return;
|
|
|
}
|
|
|
+ SysUserVo currentUser = ZHSWCommonUtils.getCurrentUser();
|
|
|
+ String dskey = currentUser.getTenantDo().getDskey();
|
|
|
+ httpServletRequest.setAttribute(Constants.SAAS_LOGIN_TOKEN, dskey);
|
|
|
generateBill(swWaterUsageEntryDoList);
|
|
|
}
|
|
|
|
|
@@ -77,7 +85,10 @@ public class BillGenerationServiceImpl {
|
|
|
public void generateBill(List<SwWaterUsageEntryDo> swWaterUsageEntryDoList) {
|
|
|
log.debug("需要生成账单的抄表记录为:{}", swWaterUsageEntryDoList);
|
|
|
SysUserVo currentUser = ZHSWCommonUtils.getCurrentUser();
|
|
|
- log.error("判断上下文对象是否正常传递:{}",currentUser);
|
|
|
+ List<SwEnterpriseConfigInfoDo> list = swEnterpriseConfigInfoService.list();
|
|
|
+ if(1==1){
|
|
|
+ throw new CustomException("");
|
|
|
+ }
|
|
|
// 对数据按照抄表日期排序
|
|
|
List<SwWaterUsageEntryDo> collect = swWaterUsageEntryDoList.stream()
|
|
|
.sorted(Comparator.comparing(SwWaterUsageEntryDo::getCurrentreadingdate))
|
|
@@ -178,23 +189,22 @@ public class BillGenerationServiceImpl {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void generateBill(List<String> ids, boolean a, ServletRequestAttributes attributes) {
|
|
|
+ public void generateBill(List<String> ids, boolean a, HttpServletRequest httpServletRequest) {
|
|
|
if (ids.isEmpty()) {
|
|
|
log.error("抄表记录ID为空");
|
|
|
return;
|
|
|
}
|
|
|
log.info("开始给抄表记录:{},生成账单信息", ids);
|
|
|
- this.asyncGenerateBill(swWaterUsageEntryService.getBaseMapper().selectBatchIds(ids), attributes);
|
|
|
+ this.asyncGenerateBill(swWaterUsageEntryService.getBaseMapper().selectBatchIds(ids), httpServletRequest);
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void generateBill(ServletRequestAttributes attributes) {
|
|
|
-
|
|
|
+ public void generateBill(HttpServletRequest request) {
|
|
|
List<SwWaterUsageEntryDo> list = swWaterUsageEntryService.list(new LambdaQueryWrapper<SwWaterUsageEntryDo>()
|
|
|
.eq(SwWaterUsageEntryDo::getDeleted, "0")
|
|
|
.eq(SwWaterUsageEntryDo::getState, 0));
|
|
|
log.info("开始给抄表记录:{},生成账单信息", list.stream().map(SwWaterUsageEntryDo::getId).collect(Collectors.toList()));
|
|
|
- this.asyncGenerateBill(list, attributes);
|
|
|
+ this.asyncGenerateBill(list, request);
|
|
|
}
|
|
|
|
|
|
/**
|