|
|
@@ -59,6 +59,7 @@ import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.Duration;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.time.Period;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -551,9 +552,17 @@ public class DatadetailController {
|
|
|
@SaCheckPermission("datadetail:detail")
|
|
|
public RT<SubscriptionStatisticsDetailVo> subscriptionStatistics(@Valid StatisticsDetailDto dto) {
|
|
|
SubscriptionStatisticsDetailVo result = new SubscriptionStatisticsDetailVo();
|
|
|
+ LocalDateTime startTime = null;
|
|
|
+ LocalDateTime endTime = null;
|
|
|
+ if(dto.getStartDate() != null){
|
|
|
+ startTime = dto.getStartDate().atStartOfDay();
|
|
|
+ }
|
|
|
+ if(dto.getEndDate() != null){
|
|
|
+ endTime = dto.getEndDate().atStartOfDay().plusDays(1).plusNanos(-1);
|
|
|
+ }
|
|
|
List<WfSubscription> list = subscriptionService.list(
|
|
|
new QueryWrapper<WfSubscription>().lambda()
|
|
|
- .between((dto.getStartDate() != null && dto.getEndDate() != null), WfSubscription::getShenQingRiQi4752, dto.getStartDate(), dto.getEndDate())
|
|
|
+ .between((startTime != null && endTime != null), WfSubscription::getShenQingRiQi4752, startTime, endTime)
|
|
|
);
|
|
|
double totalAmount = list.stream().filter(x -> x.getTotalAmount() != null && x.getStatus() == 1).mapToDouble(WfSubscription::getTotalAmount).sum();
|
|
|
result.setTotalAmount(totalAmount);
|
|
|
@@ -564,14 +573,14 @@ public class DatadetailController {
|
|
|
int pendingCount = list.stream().filter(x -> x.getStatus() == null || x.getStatus() == 0).collect(Collectors.toList()).size();
|
|
|
result.setPendingCount(pendingCount);
|
|
|
|
|
|
- String sql = "SELECT IFNULL(t3.name, '未填写') AS item,COUNT(t1.id) AS a_count,SUM(t1.estimated_unit_price) as a_sum FROM wf_subscription_list t1" +
|
|
|
+ String sql = "SELECT IFNULL(t3.name, '未填写') AS item,COUNT(t1.id) AS a_count,SUM(t1.estimated_unit_price * t1.amount) as a_sum FROM wf_subscription_list t1" +
|
|
|
" INNER JOIN wf_subscription t2 ON t1.parent_id = t2.id" +
|
|
|
" LEFT JOIN xjr_dictionary_detail t3 ON t1.item_type = t3.code" +
|
|
|
" AND t3.item_id = 1752140413593518081" +
|
|
|
" WHERE t2.status = 1";
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- if(dto.getStartDate() != null && dto.getEndDate() != null){
|
|
|
- sql += " and t2.shen_qing_ri_qi4752 between '" + dto.getStartDate().format(formatter) + "' and '" + dto.getEndDate().format(formatter) + "'";
|
|
|
+ if(startTime != null && endTime != null){
|
|
|
+ sql += " and t2.shen_qing_ri_qi4752 between '" + startTime.format(formatter) + "' and '" + endTime.format(formatter) + "'";
|
|
|
}
|
|
|
sql += " GROUP BY t3.name";
|
|
|
List<Map<String, Object>> datalist = SqlRunnerAdapter.db().selectList(sql);
|
|
|
@@ -595,12 +604,12 @@ public class DatadetailController {
|
|
|
result.setCategoryCountList(categoryCountList);
|
|
|
result.setCategoryAmountList(categoryAmountList);
|
|
|
|
|
|
- sql = "SELECT IFNULL(t3.name, '未填写') AS item,COUNT(t1.id) AS a_count,SUM(t1.estimated_unit_price) as a_sum FROM wf_subscription_list t1" +
|
|
|
+ sql = "SELECT IFNULL(t3.name, '未填写') AS item,COUNT(t1.id) AS a_count,SUM(t1.estimated_unit_price * t1.amount) as a_sum FROM wf_subscription_list t1" +
|
|
|
" INNER JOIN wf_subscription t2 ON t1.parent_id = t2.id" +
|
|
|
" LEFT JOIN xjr_department t3 ON t2.application_department = t3.id" +
|
|
|
" WHERE t2.status = 1";
|
|
|
- if(dto.getStartDate() != null && dto.getEndDate() != null){
|
|
|
- sql += " and t2.shen_qing_ri_qi4752 between '" + dto.getStartDate().format(formatter) + "' and '" + dto.getEndDate().format(formatter) + "'";
|
|
|
+ if(startTime != null && endTime != null){
|
|
|
+ sql += " and t2.shen_qing_ri_qi4752 between '" + startTime.format(formatter) + "' and '" + endTime.format(formatter) + "'";
|
|
|
}
|
|
|
sql += " GROUP BY t3.name";
|
|
|
datalist = SqlRunnerAdapter.db().selectList(sql);
|