|
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.area.utils.CustomizeAreaUtil;
|
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
|
import com.fjhx.common.utils.Assert;
|
|
|
+import com.fjhx.item.util.excel.util.ExcelUtil;
|
|
|
import com.fjhx.kd100.entity.company.po.CompanyInfo;
|
|
|
import com.fjhx.kd100.entity.config.po.ConfigInfo;
|
|
|
import com.fjhx.kd100.entity.logistics.po.LogisticsInfo;
|
|
@@ -22,6 +23,8 @@ import com.fjhx.kd100.util.KD100Util;
|
|
|
import com.fjhx.purchase.entity.purchase.po.Purchase;
|
|
|
import com.fjhx.purchase.service.purchase.PurchaseService;
|
|
|
import com.fjhx.victoriatourist.entity.deliver.po.DeliverGoods;
|
|
|
+import com.fjhx.victoriatourist.entity.logistics.LogisticsInfosExcelBo;
|
|
|
+import com.fjhx.victoriatourist.entity.logistics.LogisticsProductInfo;
|
|
|
import com.fjhx.victoriatourist.entity.logistics.dto.LogisticsInfosDto;
|
|
|
import com.fjhx.victoriatourist.entity.logistics.dto.LogisticsInfosSelectDto;
|
|
|
import com.fjhx.victoriatourist.entity.logistics.po.LogisticsDetails;
|
|
@@ -44,6 +47,8 @@ import org.springframework.context.event.EventListener;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -74,10 +79,7 @@ public class LogisticsInfosServiceImpl extends ServiceImpl<LogisticsInfosMapper,
|
|
|
@Autowired
|
|
|
private DeliverGoodsService deliverGoodsService;
|
|
|
|
|
|
-
|
|
|
- @Override
|
|
|
- public Page<LogisticsInfosVo> getPage(LogisticsInfosSelectDto dto) {
|
|
|
- IWrapper<LogisticsInfos> wrapper = getWrapper();
|
|
|
+ private void setPageWrapper(IWrapper<LogisticsInfos> wrapper, LogisticsInfosSelectDto dto) {
|
|
|
wrapper.eq("li", LogisticsInfos::getId, dto.getId());
|
|
|
|
|
|
wrapper.eq("li", LogisticsInfos::getBusinessType, dto.getBusinessType());
|
|
@@ -115,16 +117,41 @@ public class LogisticsInfosServiceImpl extends ServiceImpl<LogisticsInfosMapper,
|
|
|
//部门(项目组)过滤
|
|
|
wrapper.eq("de.dept_id", dto.getDeptId());
|
|
|
|
|
|
+ //时间范围过滤
|
|
|
+ wrapper.ge("li.create_time", dto.getBeginTime());
|
|
|
+ wrapper.le("li.create_time", dto.getEndTime());
|
|
|
+
|
|
|
+
|
|
|
wrapper.groupBy("li.id");
|
|
|
|
|
|
wrapper.orderByDesc("li", LogisticsInfos::getId);
|
|
|
Assert.notEmpty(dto.getBusinessType(), "物流数据来源类型不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<LogisticsInfosVo> getPage(LogisticsInfosSelectDto dto) {
|
|
|
+ IWrapper<LogisticsInfos> wrapper = getWrapper();
|
|
|
+
|
|
|
+ //设置通用查询条件
|
|
|
+ setPageWrapper(wrapper, dto);
|
|
|
+
|
|
|
Page<LogisticsInfosVo> page = this.baseMapper.getPage(dto.getPage(), wrapper, dto.getBusinessType());
|
|
|
List<LogisticsInfosVo> records = page.getRecords();
|
|
|
+
|
|
|
+ //赋值通用信息
|
|
|
+ setPageInfo(records);
|
|
|
+
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setPageInfo(List<LogisticsInfosVo> records) {
|
|
|
+ if (ObjectUtil.isEmpty(records)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
//赋值物流公司名字
|
|
|
List<String> codes = records.stream().map(LogisticsInfosVo::getLogisticsCompanyCode).collect(Collectors.toList());
|
|
|
if (ObjectUtil.isEmpty(codes)) {
|
|
|
- return page;
|
|
|
+ return;
|
|
|
}
|
|
|
List<CompanyInfo> list = companyInfoService.list(q -> q.in(CompanyInfo::getCode, codes));
|
|
|
if (ObjectUtil.isNotEmpty(list)) {
|
|
@@ -136,7 +163,56 @@ public class LogisticsInfosServiceImpl extends ServiceImpl<LogisticsInfosMapper,
|
|
|
}
|
|
|
//赋值国省市名称
|
|
|
CustomizeAreaUtil.setAreaName(records);
|
|
|
- return page;
|
|
|
+
|
|
|
+ //赋值产品信息
|
|
|
+ setProductInfo(records);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 赋值物流关联业务产品信息
|
|
|
+ */
|
|
|
+ private void setProductInfo(List<LogisticsInfosVo> records) {
|
|
|
+ if (ObjectUtil.isEmpty(records)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //采购到货
|
|
|
+ {
|
|
|
+ List<LogisticsInfosVo> collect0 = records.stream().filter(item -> item.getBusinessType().equals(1)).collect(Collectors.toList());
|
|
|
+ List<Long> ids0 = collect0.stream().map(LogisticsInfos::getId).collect(Collectors.toList());
|
|
|
+ List<LogisticsProductInfo> byDeliverGoods = baseMapper.getLogisticsProductInfoByDeliverGoods(IWrapper.getWrapper()
|
|
|
+ .in("lis.id", ids0)
|
|
|
+ );
|
|
|
+ Map<Long, List<LogisticsProductInfo>> byDeliverGoodsMap = byDeliverGoods.stream().collect(Collectors.groupingBy(LogisticsProductInfo::getId));
|
|
|
+ for (LogisticsInfosVo logisticsInfosVo : collect0) {
|
|
|
+ logisticsInfosVo.setLogisticsProductInfoList(byDeliverGoodsMap.getOrDefault(logisticsInfosVo.getId(), new ArrayList<>()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //京东数据
|
|
|
+ {
|
|
|
+ List<LogisticsInfosVo> collect1 = records.stream().filter(item -> item.getBusinessType().equals(2)).collect(Collectors.toList());
|
|
|
+ List<Long> ids1 = collect1.stream().map(LogisticsInfos::getId).collect(Collectors.toList());
|
|
|
+ List<LogisticsProductInfo> byStockWait = baseMapper.getLogisticsProductInfoByStockWait(IWrapper.getWrapper()
|
|
|
+ .in("lis.id", ids1)
|
|
|
+ );
|
|
|
+ Map<Long, List<LogisticsProductInfo>> byStockWaitMap = byStockWait.stream().collect(Collectors.groupingBy(LogisticsProductInfo::getId));
|
|
|
+ for (LogisticsInfosVo logisticsInfosVo : collect1) {
|
|
|
+ logisticsInfosVo.setLogisticsProductInfoList(byStockWaitMap.getOrDefault(logisticsInfosVo.getId(), new ArrayList<>()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //采购退货
|
|
|
+ {
|
|
|
+ List<LogisticsInfosVo> collect2 = records.stream().filter(item -> item.getBusinessType().equals(5)).collect(Collectors.toList());
|
|
|
+ List<Long> ids2 = collect2.stream().map(LogisticsInfos::getId).collect(Collectors.toList());
|
|
|
+ List<LogisticsProductInfo> byStockWait1 = baseMapper.getLogisticsProductInfoByStockWait(IWrapper.getWrapper()
|
|
|
+ .in("lis.id", ids2)
|
|
|
+ );
|
|
|
+ Map<Long, List<LogisticsProductInfo>> byStockWaitMap1 = byStockWait1.stream().collect(Collectors.groupingBy(LogisticsProductInfo::getId));
|
|
|
+ for (LogisticsInfosVo logisticsInfosVo : collect2) {
|
|
|
+ logisticsInfosVo.setLogisticsProductInfoList(byStockWaitMap1.getOrDefault(logisticsInfosVo.getId(), new ArrayList<>()));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -319,4 +395,88 @@ public class LogisticsInfosServiceImpl extends ServiceImpl<LogisticsInfosMapper,
|
|
|
TenantHolder.clear();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void exportExcel(LogisticsInfosSelectDto dto, HttpServletResponse httpServletResponse) {
|
|
|
+ IWrapper<LogisticsInfos> wrapper = getWrapper();
|
|
|
+ setPageWrapper(wrapper, dto);
|
|
|
+ List<LogisticsInfosVo> list = baseMapper.getList(wrapper, dto.getBusinessType());
|
|
|
+ setPageInfo(list);
|
|
|
+
|
|
|
+ //导出Excel
|
|
|
+ List<LogisticsInfosExcelBo> logisticsInfosExcelBoList = BeanUtil.copyToList(list, LogisticsInfosExcelBo.class);
|
|
|
+ for (LogisticsInfosExcelBo logisticsInfosExcelBo : logisticsInfosExcelBoList) {
|
|
|
+ //数据来源
|
|
|
+ if (logisticsInfosExcelBo.getBusinessType().equals("1")) {
|
|
|
+ logisticsInfosExcelBo.setBusinessType("采购入库");
|
|
|
+ }
|
|
|
+ if (logisticsInfosExcelBo.getBusinessType().equals("2")) {
|
|
|
+ logisticsInfosExcelBo.setBusinessType("京东订单出库");
|
|
|
+ }
|
|
|
+ if (logisticsInfosExcelBo.getBusinessType().equals("5")) {
|
|
|
+ logisticsInfosExcelBo.setBusinessType("采购退货");
|
|
|
+ }
|
|
|
+ // 物流状态 -1未查询到快递信息 0在途,1揽收,2疑难,3签收,4退签,5派件,6退回,7转投,8清关,14拒签,15完成
|
|
|
+ String logisticsStatus = logisticsInfosExcelBo.getLogisticsStatus();
|
|
|
+ if (ObjectUtil.isNotEmpty(logisticsStatus)) {
|
|
|
+ switch (logisticsStatus) {
|
|
|
+ case "-1":
|
|
|
+ logisticsStatus = "未知";
|
|
|
+ break;
|
|
|
+ case "0":
|
|
|
+ logisticsStatus = "在途";
|
|
|
+ break;
|
|
|
+ case "1":
|
|
|
+ logisticsStatus = "揽收";
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ logisticsStatus = "疑难";
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ logisticsStatus = "签收";
|
|
|
+ break;
|
|
|
+ case "4":
|
|
|
+ logisticsStatus = "退签";
|
|
|
+ break;
|
|
|
+ case "5":
|
|
|
+ logisticsStatus = "派件";
|
|
|
+ break;
|
|
|
+ case "6":
|
|
|
+ logisticsStatus = "退回";
|
|
|
+ break;
|
|
|
+ case "7":
|
|
|
+ logisticsStatus = "转投";
|
|
|
+ break;
|
|
|
+ case "8":
|
|
|
+ logisticsStatus = "清关";
|
|
|
+ break;
|
|
|
+ case "14":
|
|
|
+ logisticsStatus = "拒签";
|
|
|
+ break;
|
|
|
+ case "15":
|
|
|
+ logisticsStatus = "完成";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ logisticsInfosExcelBo.setLogisticsStatus(logisticsStatus);
|
|
|
+ }
|
|
|
+
|
|
|
+ //物流产品信息
|
|
|
+ List<LogisticsProductInfo> logisticsProductInfoList = logisticsInfosExcelBo.getLogisticsProductInfoList();
|
|
|
+ StringJoiner sj1 = new StringJoiner("\r\n");
|
|
|
+ StringJoiner sj2 = new StringJoiner("\r\n");
|
|
|
+ StringJoiner sj3 = new StringJoiner("\r\n");
|
|
|
+
|
|
|
+ for (LogisticsProductInfo logisticsProductInfo : logisticsProductInfoList) {
|
|
|
+ sj1.add(logisticsProductInfo.getProductCode());
|
|
|
+ sj2.add(logisticsProductInfo.getProductSpec());
|
|
|
+ sj3.add(ObjectUtil.defaultIfNull(logisticsProductInfo.getQuantity(), BigDecimal.ZERO).toString());
|
|
|
+ }
|
|
|
+ logisticsInfosExcelBo.setSku(sj1.toString());
|
|
|
+ logisticsInfosExcelBo.setProductSpec(sj2.toString());
|
|
|
+ logisticsInfosExcelBo.setQuantity(sj3.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ExcelUtil.export(httpServletResponse, logisticsInfosExcelBoList, LogisticsInfosExcelBo.class);
|
|
|
+ }
|
|
|
+
|
|
|
}
|