|
|
@@ -5,6 +5,7 @@ import com.sckw.core.common.enums.NumberConstant;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.enums.CarWaybillEnum;
|
|
|
+import com.sckw.core.model.enums.CarWaybillQueryEnum;
|
|
|
import com.sckw.core.model.page.PageResult;
|
|
|
import com.sckw.core.utils.BeanUtils;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
@@ -42,6 +43,7 @@ import org.springframework.util.ObjectUtils;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.regex.Pattern;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author jc
|
|
|
@@ -89,7 +91,7 @@ public class WaybillManagementService {
|
|
|
* @return
|
|
|
*/
|
|
|
public HttpResult waybillData(Long id) {
|
|
|
- if (Objects.isNull(id)){
|
|
|
+ if (Objects.isNull(id)) {
|
|
|
return HttpResult.error("id不能为空");
|
|
|
}
|
|
|
WaybillDataVO waybillDataVO = new WaybillDataVO();
|
|
|
@@ -202,7 +204,7 @@ public class WaybillManagementService {
|
|
|
|
|
|
List<KwtWaybillOrderTrack> kwtWaybillOrderTracks = kwtWaybillOrderTrackMapper
|
|
|
.selectList(new LambdaQueryWrapper<KwtWaybillOrderTrack>()
|
|
|
- .eq(KwtWaybillOrderTrack::getWOrderId, id));
|
|
|
+ .eq(KwtWaybillOrderTrack::getWOrderId, id));
|
|
|
List<WaybillTrackVO> waybillTrackVOS = new ArrayList<>();
|
|
|
if (CollectionUtils.isNotEmpty(kwtWaybillOrderTracks)) {
|
|
|
List<Long> userIds = new ArrayList<>();
|
|
|
@@ -407,7 +409,7 @@ public class WaybillManagementService {
|
|
|
for (SckwWaybillOrder sckwWaybillOrder : list) {
|
|
|
WaybillBoardListVO waybillBoardListVO = new WaybillBoardListVO();
|
|
|
waybillBoardListVO.setWOrderId(String.valueOf(sckwWaybillOrder.getWOrderId()));
|
|
|
- waybillBoardListVO.setWOrderNo(String.valueOf(sckwWaybillOrder.getWOrderNo()));
|
|
|
+ waybillBoardListVO.setWOrderNo(sckwWaybillOrder.getWOrderNo() == null ? null : sckwWaybillOrder.getWOrderNo());
|
|
|
waybillBoardListVO.setStatus(String.valueOf(sckwWaybillOrder.getStatus()));
|
|
|
waybillBoardListVO.setType(String.valueOf(sckwWaybillOrder.getType()));
|
|
|
waybillBoardListVO.setStatusLabel(CarWaybillEnum.getName(sckwWaybillOrder.getStatus()));
|
|
|
@@ -442,7 +444,7 @@ public class WaybillManagementService {
|
|
|
// 运单进度
|
|
|
List<KwtWaybillOrderTrack> kwtWaybillOrderTracks = kwtWaybillOrderTrackMapper
|
|
|
.selectList(new LambdaQueryWrapper<KwtWaybillOrderTrack>()
|
|
|
- .eq(KwtWaybillOrderTrack::getWOrderId, sckwWaybillOrder.getWOrderId()));
|
|
|
+ .eq(KwtWaybillOrderTrack::getWOrderId, sckwWaybillOrder.getWOrderId()));
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(kwtWaybillOrderTracks)) {
|
|
|
List<Long> userIds = new ArrayList<>();
|
|
|
@@ -498,26 +500,46 @@ public class WaybillManagementService {
|
|
|
if (CollectionUtils.isNotEmpty(wOrderIds)) {
|
|
|
Criteria.where("wOrderId").in(wOrderIds);
|
|
|
}
|
|
|
- if (StringUtils.isNotBlank(query.getStatus())) {
|
|
|
- if (query.getStatus().equals(String.valueOf(CarWaybillEnum.COMPLETION_UNLOADING.getCode()))) {
|
|
|
- List<Integer> _statuses = new ArrayList<>();
|
|
|
- _statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
|
|
|
- _statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode());
|
|
|
- criteria.and("status").in(_statuses);
|
|
|
- } else if (query.getStatus().equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO))) {
|
|
|
- List<Integer> _statuses = new ArrayList<>();
|
|
|
- _statuses.add(CarWaybillEnum.REJECT_ORDER.getCode());
|
|
|
- _statuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode());
|
|
|
- _statuses.add(CarWaybillEnum.REVOKED.getCode());
|
|
|
- criteria.and("status").in(_statuses);
|
|
|
- } else if (!query.getStatus().equals("all")
|
|
|
- && (!query.getStatus().equals(String.valueOf(CarWaybillEnum.COMPLETION_UNLOADING.getCode())))
|
|
|
- && (!query.getStatus().equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO)))
|
|
|
- ) {
|
|
|
+// if (StringUtils.isNotBlank(query.getStatus())) {
|
|
|
+// if (query.getStatus().equals(String.valueOf(CarWaybillEnum.COMPLETION_UNLOADING.getCode()))) {
|
|
|
+// List<Integer> _statuses = new ArrayList<>();
|
|
|
+// _statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
|
|
|
+// _statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode());
|
|
|
+// criteria.and("status").in(_statuses);
|
|
|
+// } else if (query.getStatus().equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO))) {
|
|
|
+// List<Integer> _statuses = new ArrayList<>();
|
|
|
+// _statuses.add(CarWaybillEnum.REJECT_ORDER.getCode());
|
|
|
+// _statuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode());
|
|
|
+// _statuses.add(CarWaybillEnum.REVOKED.getCode());
|
|
|
+// criteria.and("status").in(_statuses);
|
|
|
+// } else if (!query.getStatus().equals("all")
|
|
|
+// && (!query.getStatus().equals(String.valueOf(CarWaybillEnum.COMPLETION_UNLOADING.getCode())))
|
|
|
+// && (!query.getStatus().equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO)))
|
|
|
+// ) {
|
|
|
+// criteria.and("status").is(Integer.valueOf(query.getStatus()));
|
|
|
+// }
|
|
|
+// }
|
|
|
+ /**
|
|
|
+ * 【拒绝接单】、【拒绝出车】、【已撤销】状态在列表页的表头,都归类到【已作废】状态中;
|
|
|
+ *
|
|
|
+ * 【审核通过】、【核单驳回】、【修改审核】状态都归类于【单证审核】大类状态下
|
|
|
+ * */
|
|
|
+ if (StringUtils.isNotBlank(query.getStatus()) && (!"all".equals(query.getStatus()))) {
|
|
|
+ List<Long> statuses = new ArrayList<>();
|
|
|
+ if (query.getStatus().equals(CarWaybillQueryEnum.DOCUMENT_CHECK.getStatus())) {
|
|
|
+ statuses.add(CarWaybillEnum.APPROVAL_IN.getCode().longValue());
|
|
|
+ statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
|
|
|
+ statuses.add(CarWaybillEnum.APPROVAL_PASS.getCode().longValue());
|
|
|
+ criteria.and("status").in(statuses);
|
|
|
+ } else if (query.getStatus().equals(String.valueOf(CarWaybillQueryEnum.ABROGATE.getCode()))) {
|
|
|
+ statuses.add(CarWaybillEnum.REJECT_ORDER.getCode().longValue());
|
|
|
+ statuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode().longValue());
|
|
|
+ statuses.add(CarWaybillEnum.REVOKED.getCode().longValue());
|
|
|
+ criteria.and("status").in(statuses);
|
|
|
+ } else {
|
|
|
criteria.and("status").is(Integer.valueOf(query.getStatus()));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// 装载时间
|
|
|
if (Objects.nonNull(query.getStartLoadTime()) && Objects.nonNull(query.getEndLoadTime())) {
|
|
|
criteria.and("loadTime").gte(query.getStartLoadTime()).lte(DateUtil.offsetDay(query.getEndLoadTime(), 1));
|
|
|
@@ -597,51 +619,181 @@ public class WaybillManagementService {
|
|
|
AggregationResults<TableTops> outputTypeCount = mongoTemplate.aggregate(aggregation, SckwWaybillOrder.class, TableTops.class);
|
|
|
List<TableTops> results = outputTypeCount.getMappedResults();
|
|
|
Integer allTotal = 0;
|
|
|
- Map<String, TableTops> listMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
+ // 填充默认值
|
|
|
+ List<TableTops> list = new ArrayList<>();
|
|
|
TableTops topTotal = new TableTops();
|
|
|
topTotal.setName("全部");
|
|
|
topTotal.setValue("all");
|
|
|
- topTotal.setTotal(allTotal);
|
|
|
- listMap.put("all", topTotal);
|
|
|
- statuses.forEach(e -> {
|
|
|
- TableTops top = new TableTops();
|
|
|
- top.setValue(String.valueOf(e));
|
|
|
- top.setTotal(0);
|
|
|
- top.setName(CarWaybillEnum.getName(e));
|
|
|
- listMap.put(String.valueOf(e), top);
|
|
|
- });
|
|
|
+ topTotal.setTotal(0);
|
|
|
+
|
|
|
+ //已作废
|
|
|
+ TableTops topExpired = new TableTops();
|
|
|
+ topExpired.setName(CarWaybillQueryEnum.ABROGATE.getDestination());
|
|
|
+ topExpired.setValue(CarWaybillQueryEnum.ABROGATE.getStatus());
|
|
|
+ topExpired.setTotal(0);
|
|
|
+
|
|
|
+ //单据审核
|
|
|
+ TableTops documentCheck = new TableTops();
|
|
|
+ documentCheck.setName(CarWaybillQueryEnum.DOCUMENT_CHECK.getDestination());
|
|
|
+ documentCheck.setValue(CarWaybillQueryEnum.DOCUMENT_CHECK.getStatus());
|
|
|
+ documentCheck.setTotal(0);
|
|
|
+
|
|
|
+ list.addAll(results);
|
|
|
+ list.add(topExpired);
|
|
|
+ list.add(documentCheck);
|
|
|
+
|
|
|
+// statuses.forEach(e -> {
|
|
|
+// TableTops top = new TableTops();
|
|
|
+// top.setValue(String.valueOf(e));
|
|
|
+// top.setTotal(0);
|
|
|
+// top.setName(CarWaybillEnum.getName(e));
|
|
|
+// listMap.put(String.valueOf(e), top);
|
|
|
+// });
|
|
|
/**计算总条数*/
|
|
|
- if (CollectionUtils.isNotEmpty(results)) {
|
|
|
- for (TableTops result : results) {
|
|
|
- if (listMap.containsKey(result.getValue())) {
|
|
|
- listMap.get(result.getValue()).setTotal(result.getTotal());
|
|
|
+// if (CollectionUtils.isNotEmpty(results)) {
|
|
|
+// for (TableTops result : results) {
|
|
|
+// if (listMap.containsKey(result.getValue())) {
|
|
|
+// listMap.get(result.getValue()).setTotal(result.getTotal());
|
|
|
+// }
|
|
|
+// allTotal += result.getTotal();
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ /**数据统计计算*/
|
|
|
+ //单证审核合并计算
|
|
|
+ documentCheckNumberCount(list);
|
|
|
+ //已作废合并计算
|
|
|
+ abrogateNumberCount(list);
|
|
|
+ /**补齐全部状态值*/
|
|
|
+ List<String> codeList = CarWaybillEnum.getStringCodes();
|
|
|
+ List<String> collect = list.stream().map(e -> e.getValue()).collect(Collectors.toList());
|
|
|
+ List<String> diffrentList = getDiffrentList(collect, codeList);
|
|
|
+ for (String s : diffrentList) {
|
|
|
+ TableTops top = new TableTops();
|
|
|
+ top.setValue(s);
|
|
|
+ top.setTotal(NumberConstant.ZERO);
|
|
|
+ top.setSort(Integer.valueOf(s));
|
|
|
+ list.add(top);
|
|
|
+ }
|
|
|
+ /**状态赋值翻译*/
|
|
|
+ for (CarWaybillEnum waybillEnum : CarWaybillEnum.values()) {
|
|
|
+ for (TableTops tops : list) {
|
|
|
+ if (waybillEnum.getStatus().equals(tops.getValue())) {
|
|
|
+ tops.setName(waybillEnum.getDestination());
|
|
|
+ tops.setSort(waybillEnum.getCode());
|
|
|
+ continue;
|
|
|
}
|
|
|
- allTotal += result.getTotal();
|
|
|
}
|
|
|
}
|
|
|
+// list.add(topExpired);
|
|
|
+ /**去除不展示统计字段*/
|
|
|
+ List<TableTops> returnList = new ArrayList<>();
|
|
|
+ for (TableTops tops : list) {
|
|
|
+ if ((!CarWaybillEnum.REFUSE_TRAFFIC.getStatus().equals(tops.getValue()))
|
|
|
+ && (!CarWaybillEnum.APPROVAL_NO_PASS.getStatus().equals(tops.getValue()))
|
|
|
+ && (!CarWaybillEnum.REVOKED.getStatus().equals(tops.getValue()))
|
|
|
+ && (!CarWaybillEnum.REJECT_ORDER.getStatus().equals(tops.getValue()))
|
|
|
+ && (!CarWaybillEnum.APPROVAL_NO_PASS.getStatus().equals(tops.getValue()))
|
|
|
+ && (!CarWaybillEnum.APPROVAL_IN.getStatus().equals(tops.getValue()))
|
|
|
+ && (!CarWaybillEnum.APPROVAL_PASS.getStatus().equals(tops.getValue()))
|
|
|
+ ) {
|
|
|
+ returnList.add(tops);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**排序*/
|
|
|
+ returnList = returnList.stream().sorted(Comparator.comparing(TableTops::getSort)).collect(Collectors.toList());
|
|
|
+ allTotal = results.stream().collect(Collectors.summingInt(TableTops::getTotal));
|
|
|
// allTotal= Math.toIntExact(results.stream().filter(item -> ObjectUtil.isNotEmpty(item.getTotal())).collect(Collectors.summarizingInt(item -> item.getTotal())).getSum());
|
|
|
- listMap.get("all").setTotal(allTotal);
|
|
|
+// long sum = results.stream().filter(item -> ObjectUtil.isNotEmpty(item.getTotal())).collect(Collectors.summarizingInt(TableTops::getTotal)).getSum();
|
|
|
+ topTotal.setTotal(allTotal);
|
|
|
+ returnList.add(0, topTotal);
|
|
|
|
|
|
/**数据状态整合做计算
|
|
|
* 整合页面数据状态查询*/
|
|
|
- if (CollectionUtils.isNotEmpty(results)) {
|
|
|
- //已卸货包含本身以及审核不通过
|
|
|
- Integer number = 0;
|
|
|
+// if (CollectionUtils.isNotEmpty(results)) {
|
|
|
+// //已卸货包含本身以及审核不通过
|
|
|
+// Integer number = 0;
|
|
|
+// for (TableTops result : results) {
|
|
|
+// if (CarWaybillEnum.APPROVAL_NO_PASS.getStatus().equals(result.getValue())) {
|
|
|
+// Integer total = result.getTotal();
|
|
|
+// number = number + total;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// for (TableTops result : results) {
|
|
|
+// if (CarWaybillEnum.COMPLETION_UNLOADING.getStatus().equals(result.getValue())) {
|
|
|
+// result.setTotal(result.getTotal() + number);
|
|
|
+// listMap.put(result.getValue(), result);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ return HttpResult.ok(returnList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计top计算
|
|
|
+ *
|
|
|
+ * @param results
|
|
|
+ */
|
|
|
+ private void documentCheckNumberCount(List<TableTops> results) {
|
|
|
+ if (!org.springframework.util.CollectionUtils.isEmpty(results)) {
|
|
|
+ //单证审核计算包含审核通过、审核更新审核中以及审核不通过
|
|
|
+ Integer documentCheck = 0;
|
|
|
+ for (TableTops result : results) {
|
|
|
+ //单证审核计算
|
|
|
+ if (CarWaybillEnum.APPROVAL_IN.getStatus().equals(result.getValue())
|
|
|
+ || CarWaybillEnum.APPROVAL_NO_PASS.getStatus().equals(result.getValue())
|
|
|
+ || CarWaybillEnum.APPROVAL_PASS.getStatus().equals(result.getValue())) {
|
|
|
+ documentCheck = documentCheck + result.getTotal();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (TableTops result : results) {
|
|
|
+ if (CarWaybillQueryEnum.DOCUMENT_CHECK.getStatus().equals(result.getValue())) {
|
|
|
+ result.setTotal(documentCheck);
|
|
|
+ result.setSort(CarWaybillQueryEnum.DOCUMENT_CHECK.getCode());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计top计算
|
|
|
+ *
|
|
|
+ * @param results
|
|
|
+ */
|
|
|
+ private void abrogateNumberCount(List<TableTops> results) {
|
|
|
+ if (!org.springframework.util.CollectionUtils.isEmpty(results)) {
|
|
|
+ //已作废包含本身以及拒绝出车、已撤销、拒绝接单
|
|
|
+ Integer orderCancellation = 0;
|
|
|
for (TableTops result : results) {
|
|
|
- if (CarWaybillEnum.APPROVAL_NO_PASS.getStatus().equals(result.getValue())) {
|
|
|
- Integer total = result.getTotal();
|
|
|
- number = number + total;
|
|
|
+ //已作废计算
|
|
|
+ if (CarWaybillEnum.REJECT_ORDER.getStatus().equals(result.getValue())
|
|
|
+ || CarWaybillEnum.REVOKED.getStatus().equals(result.getValue())
|
|
|
+ || CarWaybillEnum.REFUSE_TRAFFIC.getStatus().equals(result.getValue())
|
|
|
+ ) {
|
|
|
+ orderCancellation = orderCancellation + result.getTotal();
|
|
|
}
|
|
|
}
|
|
|
for (TableTops result : results) {
|
|
|
- if (CarWaybillEnum.COMPLETION_UNLOADING.getStatus().equals(result.getValue())) {
|
|
|
- result.setTotal(result.getTotal() + number);
|
|
|
- listMap.put(result.getValue(), result);
|
|
|
+ if (CarWaybillQueryEnum.ABROGATE.getStatus().equals(result.getValue())) {
|
|
|
+ result.setTotal(orderCancellation);
|
|
|
+ result.setSort(CarWaybillQueryEnum.ABROGATE.getCode());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- return HttpResult.ok(listMap.values());
|
|
|
+ /**
|
|
|
+ * @param sourceList 源数据 [1]
|
|
|
+ * @param targetList 目标数据 [1,2,3]
|
|
|
+ * @Description: 获取targetList中在sourceList中不存在的项
|
|
|
+ * @return: List<String> [2,3]
|
|
|
+ */
|
|
|
+ public List<String> getDiffrentList(List<String> sourceList, List<String> targetList) {
|
|
|
+ return targetList.stream().filter(item -> sourceList.stream().allMatch(each -> !item.equals(each))).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
/**
|