|
|
@@ -17,6 +17,7 @@ import com.sckw.report.service.param.ConsignOrderQuery;
|
|
|
import com.sckw.report.service.param.WaybillOrderQuery;
|
|
|
import com.sckw.report.service.vo.CarWaybillVo;
|
|
|
import com.sckw.report.service.vo.ConsignOrderVo;
|
|
|
+import com.sckw.report.service.vo.WaybillsCountVo;
|
|
|
import com.sckw.transport.api.dubbo.TransportDubboService;
|
|
|
import com.sckw.transport.api.model.dto.vo.KwtLogisticsOrderVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -335,45 +336,7 @@ public class KwTransportService {
|
|
|
* @date 2023/07/21
|
|
|
*/
|
|
|
public HttpResult getWaybillOrders(WaybillOrderQuery query) throws ParseException {
|
|
|
- // 模糊匹配
|
|
|
- // 根据条件查询所有并排序,且分页
|
|
|
- // 设置模糊查询匹配规则 忽略大小写
|
|
|
- // 创建条件对象
|
|
|
- Criteria criteria = new Criteria();
|
|
|
- criteria.and("entId").is(LoginUserHolder.getEntId());
|
|
|
- criteria.and("delFlag").is(NumberConstant.ZERO);
|
|
|
- // 装载时间
|
|
|
- if (StringUtils.isNotBlank(query.getStartLoadTime()) && StringUtils.isNotEmpty(query.getEndLoadTime())) {
|
|
|
- criteria.andOperator(Criteria.where("loadTime").gte(query.getStartLoadTime()), Criteria.where("loadTime")
|
|
|
- .lte(query.getEndLoadTime()));
|
|
|
- }
|
|
|
- // 派车时间
|
|
|
- if (StringUtils.isNotBlank(query.getStartSendCarTime()) && StringUtils.isNotEmpty(query.getEndSendCarTime())) {
|
|
|
- criteria.andOperator(Criteria.where("sendCarTime").gte(query.getStartSendCarTime()), Criteria.where("sendCarTime")
|
|
|
- .lte(query.getEndSendCarTime()));
|
|
|
- }
|
|
|
- // 卸货时间
|
|
|
- if (StringUtils.isNotBlank(query.getStartUnloadTime()) && StringUtils.isNotEmpty(query.getEndUnloadTime())) {
|
|
|
- criteria.andOperator(Criteria.where("unloadTime").gte(query.getStartUnloadTime()), Criteria.where("unloadTime")
|
|
|
- .lte(query.getEndUnloadTime()));
|
|
|
- }
|
|
|
- // 多条件模糊查询
|
|
|
- Criteria c1 = new Criteria();
|
|
|
- Criteria c2 = new Criteria();
|
|
|
- Criteria c3 = new Criteria();
|
|
|
- Criteria c4 = new Criteria();
|
|
|
- Criteria c5 = new Criteria();
|
|
|
- Criteria c6 = new Criteria();
|
|
|
- if (StringUtils.isNotBlank(query.getKeywords())) {
|
|
|
- Pattern pattern = Pattern.compile("^.*" + query.getKeywords() + ".*$", Pattern.CASE_INSENSITIVE);
|
|
|
- c1 = Criteria.where("wOrderNo").regex(pattern);
|
|
|
- c2 = Criteria.where("truckNo").regex(pattern);
|
|
|
- c3 = Criteria.where("driverName").regex(pattern);
|
|
|
- c4 = Criteria.where("firmName").regex(pattern);
|
|
|
- c5 = Criteria.where("loadAddress").regex(pattern);
|
|
|
- c6 = Criteria.where("unloadAddress").regex(pattern);
|
|
|
- criteria.orOperator(c1, c2, c3, c4, c5, c6);
|
|
|
- }
|
|
|
+ Criteria criteria = buildWaybillOrdersQuery(query);
|
|
|
Query queryFormat = new Query(criteria);
|
|
|
// in查询
|
|
|
if (CollectionUtils.isNotEmpty(query.getIds())) {
|
|
|
@@ -394,17 +357,14 @@ public class KwTransportService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 运单管理-运单列表 top 统计
|
|
|
- *
|
|
|
- * @param query 查询
|
|
|
- * @return {@link HttpResult }
|
|
|
- * @author jc
|
|
|
- * @date 2023/07/21
|
|
|
+ * 构造运单关联查询条件
|
|
|
+ * @param query
|
|
|
+ * @return
|
|
|
*/
|
|
|
- public HttpResult getWayBillStatistics(WaybillOrderQuery query){
|
|
|
- //模糊匹配
|
|
|
- //根据条件查询所有并排序,且分页
|
|
|
- //设置模糊查询匹配规则 忽略大小写
|
|
|
+ public Criteria buildWaybillOrdersQuery(WaybillOrderQuery query) {
|
|
|
+ // 模糊匹配
|
|
|
+ // 根据条件查询所有并排序,且分页
|
|
|
+ // 设置模糊查询匹配规则 忽略大小写
|
|
|
// 创建条件对象
|
|
|
Criteria criteria = new Criteria();
|
|
|
criteria.and("entId").is(LoginUserHolder.getEntId());
|
|
|
@@ -445,6 +405,19 @@ public class KwTransportService {
|
|
|
c6 = Criteria.where("unloadAddress").regex(pattern);
|
|
|
criteria.orOperator(c1, c2, c3, c4, c5, c6);
|
|
|
}
|
|
|
+ return criteria;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 运单管理-运单列表 top 统计
|
|
|
+ *
|
|
|
+ * @param query 查询
|
|
|
+ * @return {@link HttpResult }
|
|
|
+ * @author jc
|
|
|
+ * @date 2023/07/21
|
|
|
+ */
|
|
|
+ public HttpResult getWayBillStatistics(WaybillOrderQuery query){
|
|
|
+ Criteria criteria = buildWaybillOrdersQuery(query);
|
|
|
Aggregation aggregation = Aggregation.newAggregation(
|
|
|
Aggregation.match(criteria),
|
|
|
Aggregation.group("status").count().as("total"),
|
|
|
@@ -483,76 +456,22 @@ public class KwTransportService {
|
|
|
*/
|
|
|
public HttpResult wayBillTotalCount(WaybillOrderQuery query){
|
|
|
// 统计项字段
|
|
|
- Criteria criteria = new Criteria();
|
|
|
- criteria.and("entId").is(LoginUserHolder.getEntId());
|
|
|
- criteria.and("delFlag").is(NumberConstant.ZERO);
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(query.getStatus())) {
|
|
|
- criteria.and("status").is(query.getStatus());
|
|
|
- }
|
|
|
- // 装载时间
|
|
|
- if (StringUtils.isNotBlank(query.getStartLoadTime()) && StringUtils.isNotEmpty(query.getEndLoadTime())) {
|
|
|
- criteria.andOperator(Criteria.where("loadTime").gte(query.getStartLoadTime()), Criteria.where("loadTime")
|
|
|
- .lte(query.getEndLoadTime()));
|
|
|
- }
|
|
|
- // 派车时间
|
|
|
- if (StringUtils.isNotBlank(query.getStartSendCarTime()) && StringUtils.isNotEmpty(query.getEndSendCarTime())) {
|
|
|
- criteria.andOperator(Criteria.where("sendCarTime").gte(query.getStartSendCarTime()), Criteria.where("sendCarTime")
|
|
|
- .lte(query.getEndSendCarTime()));
|
|
|
- }
|
|
|
- // 卸货时间
|
|
|
- if (StringUtils.isNotBlank(query.getStartUnloadTime()) && StringUtils.isNotEmpty(query.getEndUnloadTime())) {
|
|
|
- criteria.andOperator(Criteria.where("unloadTime").gte(query.getStartUnloadTime()), Criteria.where("unloadTime")
|
|
|
- .lte(query.getEndUnloadTime()));
|
|
|
- }
|
|
|
- // 多条件模糊查询
|
|
|
- Criteria c1 = new Criteria();
|
|
|
- Criteria c2 = new Criteria();
|
|
|
- Criteria c3 = new Criteria();
|
|
|
- Criteria c4 = new Criteria();
|
|
|
- Criteria c5 = new Criteria();
|
|
|
- Criteria c6 = new Criteria();
|
|
|
- if (StringUtils.isNotBlank(query.getKeywords())) {
|
|
|
- Pattern pattern = Pattern.compile("^.*" + query.getKeywords() + ".*$", Pattern.CASE_INSENSITIVE);
|
|
|
- c1 = Criteria.where("wOrderNo").regex(pattern);
|
|
|
- c2 = Criteria.where("truckNo").regex(pattern);
|
|
|
- c3 = Criteria.where("driverName").regex(pattern);
|
|
|
- c4 = Criteria.where("firmName").regex(pattern);
|
|
|
- c5 = Criteria.where("loadAddress").regex(pattern);
|
|
|
- c6 = Criteria.where("unloadAddress").regex(pattern);
|
|
|
- criteria.orOperator(c1, c2, c3, c4, c5, c6);
|
|
|
- }
|
|
|
+ Criteria criteria = buildWaybillOrdersQuery(query);
|
|
|
Aggregation aggregation = Aggregation.newAggregation(
|
|
|
Aggregation.match(criteria),
|
|
|
- Aggregation.group("status").count().as("total"),
|
|
|
- Aggregation.project("total").and("value").previousOperation()
|
|
|
+ Aggregation.group("id").count().as("countTotal")
|
|
|
+ .sum("entrustAmount").as("entrustTotal")
|
|
|
+ .sum("loadAmount").as("loadTotal")
|
|
|
+ .sum("unloadAmount").as("unloadTotal"),
|
|
|
+ Aggregation.project("countTotal", "entrustTotal", "loadTotal", "unloadTotal")
|
|
|
);
|
|
|
- AggregationResults<TobleTop> outputTypeCount = mongoTemplate.aggregate(aggregation, SckwWaybillOrder.class, TobleTop.class);
|
|
|
- List<TobleTop> results = outputTypeCount.getMappedResults();
|
|
|
- // 填充默认值
|
|
|
- List<TobleTop> list = new ArrayList<>();
|
|
|
- for (CarWaybillEnum status:CarWaybillEnum.values()) {
|
|
|
- TobleTop top = new TobleTop();
|
|
|
- top.setName(status.getDestination());
|
|
|
- top.setValue(String.valueOf(status.getCode()));
|
|
|
- top.setTotal(0);
|
|
|
- if(CollectionUtils.isNotEmpty(results)) {
|
|
|
- for (TobleTop result:results) {
|
|
|
- if(StringUtils.isNotEmpty(result.getValue()) && String.valueOf(result.getValue()).equals(String.valueOf(status.getCode()))) {
|
|
|
- top.setTotal(result.getTotal());
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- list.add(top);
|
|
|
- }
|
|
|
-
|
|
|
- // 查询结果
|
|
|
- return HttpResult.ok(list);
|
|
|
+ AggregationResults<WaybillsCountVo> outputTypeCount = mongoTemplate.aggregate(aggregation, SckwWaybillOrder.class, WaybillsCountVo.class);
|
|
|
+ List<WaybillsCountVo> results = outputTypeCount.getMappedResults();
|
|
|
+ return HttpResult.ok(results);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 处理运单查询结果
|
|
|
+ * 运单处理运单查询结果
|
|
|
* @param list
|
|
|
* @param returnList
|
|
|
*/
|
|
|
@@ -584,6 +503,14 @@ public class KwTransportService {
|
|
|
null : DateUtil.getDateTime(waybillOrder.getLoadTime()));
|
|
|
vo.setUnloadTime(waybillOrder.getUnloadTime() == null ?
|
|
|
null :DateUtil.getDateTime(waybillOrder.getUnloadTime()));
|
|
|
+ vo.setCreateTime(waybillOrder.getCreateTime() == null ?
|
|
|
+ null : DateUtil.getDateTime(waybillOrder.getCreateTime()));
|
|
|
+ vo.setUpdateTime(waybillOrder.getUpdateTime() == null ?
|
|
|
+ null :DateUtil.getDateTime(waybillOrder.getUpdateTime()));
|
|
|
+ vo.setDeficitAmount(waybillOrder.getDeficitAmount() == null ?
|
|
|
+ null :String.valueOf(waybillOrder.getDeficitAmount()));
|
|
|
+ vo.setGoodsPriceUnit(waybillOrder.getGoodsPriceUnit() == null ?
|
|
|
+ null :String.valueOf(waybillOrder.getGoodsPriceUnit()));
|
|
|
returnList.add(vo);
|
|
|
}
|
|
|
}
|