|
@@ -5,7 +5,6 @@ import com.rongwe.zhsw.system.domain.SwBillManagementUnpaidDo;
|
|
|
import com.rongwe.zhsw.system.domain.SwUserManagementDo;
|
|
|
import com.rongwe.zhsw.system.domain.SwWaterUsageEntryDo;
|
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
|
-import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.zhsw.system.utils.ZHSWCommonUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -16,7 +15,6 @@ import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.TransactionDefinition;
|
|
|
import org.springframework.transaction.TransactionStatus;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
@@ -25,8 +23,6 @@ import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static org.springframework.transaction.annotation.Propagation.REQUIRED;
|
|
|
-
|
|
|
/**
|
|
|
* BillGenerationServiceImpl class
|
|
|
*
|
|
@@ -104,7 +100,7 @@ public class BillGenerationServiceImpl {
|
|
|
log.error("当前用户:{},时间:{}的抄表记录已生成账单信息", usernumber, currentreadingdate);
|
|
|
return;
|
|
|
}
|
|
|
- SwUserManagementDo swUserManagementDo = userMap.getOrDefault(swWaterUsageEntry.getUsernumber(),null);
|
|
|
+ SwUserManagementDo swUserManagementDo = userMap.getOrDefault(swWaterUsageEntry.getUsernumber(), null);
|
|
|
|
|
|
SwWaterUsageEntryDo usageEntryDo = new SwWaterUsageEntryDo();
|
|
|
usageEntryDo.setId(swWaterUsageEntry.getId());
|
|
@@ -122,18 +118,18 @@ public class BillGenerationServiceImpl {
|
|
|
saveUsageEntryList.add(usageEntryDo);
|
|
|
return;
|
|
|
}
|
|
|
- SwBillManagementUnpaidDo swBillManagementUnpaidDo=null;
|
|
|
+ SwBillManagementUnpaidDo swBillManagementUnpaidDo = null;
|
|
|
try {
|
|
|
// 生成代缴费账单
|
|
|
- swBillManagementUnpaidDo= produceBill(swUserManagementDo, swWaterUsageEntry);
|
|
|
- }catch (Exception e) {
|
|
|
+ swBillManagementUnpaidDo = produceBill(swUserManagementDo, swWaterUsageEntry);
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- log.error("缴费记录生成失败原因:{}",e.getMessage());
|
|
|
+ log.error("缴费记录生成失败原因:{}", e.getMessage());
|
|
|
}
|
|
|
|
|
|
- if(swBillManagementUnpaidDo==null){
|
|
|
+ if (swBillManagementUnpaidDo == null) {
|
|
|
usageEntryDo.setState(4);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
usageEntryDo.setState(1);
|
|
|
saveList.add(swBillManagementUnpaidDo);
|
|
|
// 设置本次的抄表日期
|
|
@@ -144,7 +140,7 @@ public class BillGenerationServiceImpl {
|
|
|
userSaveList.add(swUserManagementDo);
|
|
|
saveUsageEntryList.add(usageEntryDo);
|
|
|
});
|
|
|
- dataSave(saveList, saveUsageEntryList,userSaveList);
|
|
|
+ dataSave(saveList, saveUsageEntryList, userSaveList);
|
|
|
}
|
|
|
|
|
|
@Async(value = "customThreadPool")
|
|
@@ -152,6 +148,7 @@ public class BillGenerationServiceImpl {
|
|
|
SwWaterUsageEntryDo swWaterUsageEntryDo = swWaterUsageEntryService.getById(id);
|
|
|
this.generateBill(Collections.singletonList(swWaterUsageEntryDo));
|
|
|
}
|
|
|
+
|
|
|
@Async(value = "customThreadPool")
|
|
|
public void generateBill(List<String> ids, boolean a) {
|
|
|
if (ids.isEmpty()) {
|
|
@@ -160,6 +157,7 @@ public class BillGenerationServiceImpl {
|
|
|
}
|
|
|
this.generateBill(swWaterUsageEntryService.getBaseMapper().selectBatchIds(ids));
|
|
|
}
|
|
|
+
|
|
|
@Async(value = "customThreadPool")
|
|
|
public void generateBill() {
|
|
|
List<SwWaterUsageEntryDo> list = swWaterUsageEntryService.list(new LambdaQueryWrapper<SwWaterUsageEntryDo>()
|
|
@@ -170,26 +168,27 @@ public class BillGenerationServiceImpl {
|
|
|
|
|
|
/**
|
|
|
* 数据保存
|
|
|
+ *
|
|
|
* @param swBillManagementUnpaidDos 账单信息
|
|
|
- * @param userSaveList 用户信息
|
|
|
- * @param saveUsageEntryList 抄表记录
|
|
|
+ * @param userSaveList 用户信息
|
|
|
+ * @param saveUsageEntryList 抄表记录
|
|
|
*/
|
|
|
|
|
|
public void dataSave(List<SwBillManagementUnpaidDo> swBillManagementUnpaidDos,
|
|
|
- List<SwWaterUsageEntryDo> saveUsageEntryList,List<SwUserManagementDo> userSaveList) {
|
|
|
+ List<SwWaterUsageEntryDo> saveUsageEntryList, List<SwUserManagementDo> userSaveList) {
|
|
|
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
|
|
|
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
|
|
TransactionStatus status = transactionManager.getTransaction(def);
|
|
|
try {
|
|
|
- if(!saveUsageEntryList.isEmpty()){
|
|
|
+ if (!saveUsageEntryList.isEmpty()) {
|
|
|
// 抄表记录状态更新
|
|
|
- swWaterUsageEntryService.updateBatchById(saveUsageEntryList,4000);
|
|
|
+ swWaterUsageEntryService.updateBatchById(saveUsageEntryList, 4000);
|
|
|
}
|
|
|
- if(!swBillManagementUnpaidDos.isEmpty()){
|
|
|
+ if (!swBillManagementUnpaidDos.isEmpty()) {
|
|
|
// 账单保存
|
|
|
swBillManagementUnpaidService.saveBatch(swBillManagementUnpaidDos, 1000);
|
|
|
}
|
|
|
- if(!userSaveList.isEmpty()){
|
|
|
+ if (!userSaveList.isEmpty()) {
|
|
|
// 更新用户表的本次抄表时间和本次抄表度数
|
|
|
swUserManagementService.updateBatchById(userSaveList);
|
|
|
}
|
|
@@ -262,7 +261,7 @@ public class BillGenerationServiceImpl {
|
|
|
swBillManagementUnpaidDo.setWatertype(swUserManagementDo.getWatertype());
|
|
|
// 实际应缴=原应缴-减免
|
|
|
BigDecimal subtract = swBillManagementUnpaidDo.getOughttohavepaid().subtract(swBillManagementUnpaidDo.getFeewaiver());
|
|
|
- swBillManagementUnpaidDo.setActualdue(subtract.compareTo(BigDecimal.ZERO)>0?subtract:BigDecimal.ZERO);
|
|
|
+ swBillManagementUnpaidDo.setActualdue(subtract.compareTo(BigDecimal.ZERO) > 0 ? subtract : BigDecimal.ZERO);
|
|
|
swBillManagementUnpaidDo.setLastmeterreadingdate(swWaterUsageEntryDo.getLastreadingdate());
|
|
|
swBillManagementUnpaidDo.setLastmeterreading(swWaterUsageEntryDo.getLastreading());
|
|
|
swBillManagementUnpaidDo.setThismeterreadingdate(swWaterUsageEntryDo.getCurrentreadingdate());
|