|
|
@@ -39,10 +39,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -200,14 +197,17 @@ public class KwTransportService {
|
|
|
statuses.add(CarWaybillEnum.REJECT_ORDER.getCode().longValue());
|
|
|
statuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode().longValue());
|
|
|
statuses.add(CarWaybillEnum.REVOKED.getCode().longValue());
|
|
|
- statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
|
|
|
+// statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
|
|
|
criteria.and("status").in(statuses);
|
|
|
} else if (query.getStatus().equals(String.valueOf(CarWaybillEnum.COMPLETION_UNLOADING.getCode()))) {
|
|
|
List<Long> statuses = new ArrayList<>();
|
|
|
statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode().longValue());
|
|
|
statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
|
|
|
criteria.and("status").in(statuses);
|
|
|
- } else if (!query.getStatus().equals("all")) {
|
|
|
+ } 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()));
|
|
|
}
|
|
|
}
|
|
|
@@ -293,45 +293,122 @@ public class KwTransportService {
|
|
|
topTotal.setName("全部");
|
|
|
topTotal.setValue("all");
|
|
|
topTotal.setTotal(0);
|
|
|
- list.add(topTotal);
|
|
|
+
|
|
|
|
|
|
TableTops topExpired = new TableTops();
|
|
|
topExpired.setName("已作废");
|
|
|
topExpired.setValue(String.valueOf(NumberConstant.ONE_ZERO_ZERO));
|
|
|
+ topExpired.setSort(NumberConstant.ONE_ZERO_ZERO);
|
|
|
topExpired.setTotal(0);
|
|
|
- ArrayList<Long> expiredStatuses = new ArrayList<>();
|
|
|
- expiredStatuses.add(CarWaybillEnum.REJECT_ORDER.getCode().longValue());
|
|
|
- expiredStatuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode().longValue());
|
|
|
- expiredStatuses.add(CarWaybillEnum.REVOKED.getCode().longValue());
|
|
|
- expiredStatuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
|
|
|
- for (CarWaybillEnum status : CarWaybillEnum.values()) {
|
|
|
- boolean expiredFlag = expiredStatuses.contains(status.getCode().longValue());
|
|
|
+
|
|
|
+ list.addAll(results);
|
|
|
+ list.add(topExpired);
|
|
|
+// ArrayList<Long> expiredStatuses = new ArrayList<>();
|
|
|
+// expiredStatuses.add(CarWaybillEnum.REJECT_ORDER.getCode().longValue());
|
|
|
+// expiredStatuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode().longValue());
|
|
|
+// expiredStatuses.add(CarWaybillEnum.REVOKED.getCode().longValue());
|
|
|
+// expiredStatuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
|
|
|
+// for (CarWaybillEnum status : CarWaybillEnum.values()) {
|
|
|
+// boolean expiredFlag = expiredStatuses.contains(status.getCode().longValue());
|
|
|
+// TableTops top = new TableTops();
|
|
|
+// top.setName(status.getDestination());
|
|
|
+// top.setValue(String.valueOf(status.getCode()));
|
|
|
+// top.setTotal(0);
|
|
|
+// if (CollectionUtils.isNotEmpty(results)) {
|
|
|
+// for (TableTops result : results) {
|
|
|
+// if (StringUtils.isNotEmpty(result.getValue())
|
|
|
+// && String.valueOf(result.getValue()).equals(String.valueOf(status.getCode()))) {
|
|
|
+// if (expiredFlag) {
|
|
|
+// topExpired.setTotal(topExpired.getTotal() + result.getTotal());
|
|
|
+// } else {
|
|
|
+// top.setTotal(result.getTotal());
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (!expiredFlag) {
|
|
|
+// list.add(top);
|
|
|
+// }
|
|
|
+// }
|
|
|
+ /**数据统计计算*/
|
|
|
+ orderNumberCount(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.setName(status.getDestination());
|
|
|
- top.setValue(String.valueOf(status.getCode()));
|
|
|
- top.setTotal(0);
|
|
|
- if (CollectionUtils.isNotEmpty(results)) {
|
|
|
- for (TableTops result : results) {
|
|
|
- if (StringUtils.isNotEmpty(result.getValue())
|
|
|
- && String.valueOf(result.getValue()).equals(String.valueOf(status.getCode()))) {
|
|
|
- if (expiredFlag) {
|
|
|
- topExpired.setTotal(topExpired.getTotal() + result.getTotal());
|
|
|
- } else {
|
|
|
- top.setTotal(result.getTotal());
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
+ 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;
|
|
|
}
|
|
|
}
|
|
|
- if (!expiredFlag) {
|
|
|
- list.add(top);
|
|
|
+ }
|
|
|
+// 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()))
|
|
|
+ ) {
|
|
|
+ returnList.add(tops);
|
|
|
}
|
|
|
}
|
|
|
- list.add(topExpired);
|
|
|
+ /**排序*/
|
|
|
+ returnList = returnList.stream().sorted(Comparator.comparing(TableTops::getSort)).collect(Collectors.toList());
|
|
|
+ returnList.add(0,topTotal);
|
|
|
// 总计
|
|
|
- topTotal.setTotal(list.parallelStream().mapToInt(item -> item.getTotal()).sum());
|
|
|
+ topTotal.setTotal(returnList.parallelStream().mapToInt(item -> item.getTotal()).sum());
|
|
|
// 查询结果
|
|
|
- return HttpResult.ok(list);
|
|
|
+ return HttpResult.ok(returnList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计top计算
|
|
|
+ *
|
|
|
+ * @param results
|
|
|
+ */
|
|
|
+ private void orderNumberCount(List<TableTops> results) {
|
|
|
+ if (!org.springframework.util.CollectionUtils.isEmpty(results)) {
|
|
|
+ //已卸货包含本身以及审核不通过
|
|
|
+ Integer orderCancel = 0;
|
|
|
+ //已作废包含本身以及拒绝出车、已撤销、拒绝接单
|
|
|
+ Integer orderCancellation = 0;
|
|
|
+ for (TableTops result : results) {
|
|
|
+ if (CarWaybillEnum.COMPLETION_UNLOADING.getStatus().equals(result.getValue())
|
|
|
+ || CarWaybillEnum.APPROVAL_NO_PASS.getStatus().equals(result.getValue())) {
|
|
|
+ orderCancel = orderCancel + result.getTotal();
|
|
|
+ }
|
|
|
+ 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(orderCancel);
|
|
|
+ result.setSort(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
|
|
|
+ }
|
|
|
+ if (String.valueOf(NumberConstant.ONE_ZERO_ZERO).equals(result.getValue())) {
|
|
|
+ result.setTotal(orderCancellation);
|
|
|
+ result.setSort(NumberConstant.ONE_ZERO_ZERO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -383,7 +460,7 @@ public class KwTransportService {
|
|
|
typeString = "循环";
|
|
|
}
|
|
|
vo.setTypeLabel(typeString);
|
|
|
- if(status.equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO))) {
|
|
|
+ if (status.equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO))) {
|
|
|
vo.setStatus(String.valueOf(NumberConstant.ONE_ZERO_ZERO));
|
|
|
} else {
|
|
|
vo.setStatus(waybillOrder.getStatus() == null ?
|
|
|
@@ -424,12 +501,12 @@ public class KwTransportService {
|
|
|
// 存在装卸货差时 计算扣亏量
|
|
|
BigDecimal lossAmount = BigDecimal.valueOf(0);
|
|
|
BigDecimal loss = waybillOrder.getLoss() == null ? new BigDecimal("0.00") : waybillOrder.getLoss();
|
|
|
- if(deficitAmount.compareTo(new BigDecimal("0.00")) > 0 && loss.compareTo(new BigDecimal("0.00")) > 0) {
|
|
|
+ if (deficitAmount.compareTo(new BigDecimal("0.00")) > 0 && loss.compareTo(new BigDecimal("0.00")) > 0) {
|
|
|
String lossUnit = waybillOrder.getLossUnit();
|
|
|
Map<String, SysDictResDto> LossUnitType = remoteSystemService.queryDictMapByType(DictTypeEnum.TAX_RATE_TYPE.getType());
|
|
|
SysDictResDto sysDictRes = LossUnitType.get(lossUnit);
|
|
|
|
|
|
- if(sysDictRes.getLabel().equals("%")) {
|
|
|
+ if (sysDictRes.getLabel().equals("%")) {
|
|
|
// 百分比
|
|
|
lossAmount = loss.multiply(waybillOrder.getLoadAmount()).divide(BigDecimal.valueOf(100));
|
|
|
} else {
|
|
|
@@ -437,7 +514,7 @@ public class KwTransportService {
|
|
|
lossAmount = loss.multiply(waybillOrder.getLoadAmount()).divide(BigDecimal.valueOf(1000));
|
|
|
}
|
|
|
lossAmount = deficitAmount.subtract(lossAmount);
|
|
|
- if(lossAmount.compareTo(new BigDecimal("0.00")) < 0) {
|
|
|
+ if (lossAmount.compareTo(new BigDecimal("0.00")) < 0) {
|
|
|
lossAmount = new BigDecimal("0.00");
|
|
|
}
|
|
|
}
|
|
|
@@ -500,16 +577,16 @@ public class KwTransportService {
|
|
|
public HttpResult getLogisticsOrderByContractId(ContractParam contractParam) {
|
|
|
HttpResult result = new HttpResult();
|
|
|
if (String.valueOf(NumberConstant.ONE).equals(contractParam.getContractType())) {
|
|
|
- result = getLogisticsOrderContract(contractParam,"1");
|
|
|
+ result = getLogisticsOrderContract(contractParam, "1");
|
|
|
} else if (String.valueOf(NumberConstant.TWO).equals(contractParam.getContractType())) {
|
|
|
- result = getLogisticsOrderContract(contractParam,"2");
|
|
|
+ result = getLogisticsOrderContract(contractParam, "2");
|
|
|
} else {
|
|
|
return HttpResult.error("合同类型错误");
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private HttpResult getLogisticsOrderContract(ContractParam contractParam,String unitType) {
|
|
|
+ private HttpResult getLogisticsOrderContract(ContractParam contractParam, String unitType) {
|
|
|
String contractIds = contractParam.getContractIds();
|
|
|
int page = contractParam.getPage();
|
|
|
int pageSize = contractParam.getPageSize();
|
|
|
@@ -550,7 +627,7 @@ public class KwTransportService {
|
|
|
// 12. 总记录数
|
|
|
long total = mongoTemplate.count(query1, SckwLogisticsOrder.class);
|
|
|
// 10. 分页
|
|
|
- query1.with(PageRequest.of(page - 1, pageSize, Sort.by(Sort.Direction.DESC,"contractId","createTime")));
|
|
|
+ query1.with(PageRequest.of(page - 1, pageSize, Sort.by(Sort.Direction.DESC, "contractId", "createTime")));
|
|
|
// 执行查询
|
|
|
List<SckwLogisticsOrder> list = mongoTemplate.find(query1, SckwLogisticsOrder.class);
|
|
|
//字典等数据转换
|
|
|
@@ -610,7 +687,8 @@ public class KwTransportService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 运单列表导出
|
|
|
+ * 运单列表导出
|
|
|
+ *
|
|
|
* @param query
|
|
|
* @return
|
|
|
*/
|