|
@@ -0,0 +1,148 @@
|
|
|
|
+package com.fjhx.victoriatourist.service.logistics.impl;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.fjhx.kd100.entity.company.po.CompanyInfo;
|
|
|
|
+import com.fjhx.kd100.service.company.CompanyInfoService;
|
|
|
|
+import com.fjhx.kd100.util.KD100Result;
|
|
|
|
+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.logistics.dto.LogisticsInfosDto;
|
|
|
|
+import com.fjhx.victoriatourist.entity.logistics.dto.LogisticsInfosSelectDto;
|
|
|
|
+import com.fjhx.victoriatourist.entity.logistics.po.LogisticsDetails;
|
|
|
|
+import com.fjhx.victoriatourist.entity.logistics.po.LogisticsInfos;
|
|
|
|
+import com.fjhx.victoriatourist.entity.logistics.vo.LogisticsInfosVo;
|
|
|
|
+import com.fjhx.victoriatourist.mapper.logistics.LogisticsInfosMapper;
|
|
|
|
+import com.fjhx.victoriatourist.service.logistics.LogisticsDetailsService;
|
|
|
|
+import com.fjhx.victoriatourist.service.logistics.LogisticsInfosService;
|
|
|
|
+import com.fjhx.victoriatourist.utils.Assert;
|
|
|
|
+import com.fjhx.victoriatourist.utils.LogisticsConstant;
|
|
|
|
+import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * <p>
|
|
|
|
+ * 物流信息 服务实现类
|
|
|
|
+ * </p>
|
|
|
|
+ *
|
|
|
|
+ * @author
|
|
|
|
+ * @since 2023-04-17
|
|
|
|
+ */
|
|
|
|
+@Service
|
|
|
|
+public class LogisticsInfosServiceImpl extends ServiceImpl<LogisticsInfosMapper, LogisticsInfos> implements LogisticsInfosService {
|
|
|
|
+ @Autowired
|
|
|
|
+ CompanyInfoService companyInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ LogisticsDetailsService logisticsDetailsService;
|
|
|
|
+ @Autowired
|
|
|
|
+ PurchaseService purchaseService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Page<LogisticsInfosVo> getPage(LogisticsInfosSelectDto dto) {
|
|
|
|
+ IWrapper<LogisticsInfos> wrapper = getWrapper();
|
|
|
|
+ wrapper.eq(LogisticsInfos::getBusinessType, dto.getBusinessType());
|
|
|
|
+ wrapper.eq(LogisticsInfos::getLogisticsStatus, dto.getLogisticsStatus());
|
|
|
|
+ wrapper.eq(LogisticsInfos::getStatus, dto.getStatus());
|
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
|
|
|
|
+ wrapper.and(q -> q.like(LogisticsInfos::getCode, dto.getKeyword())
|
|
|
|
+ .or().like(LogisticsInfos::getBusinessCode, dto.getKeyword()));
|
|
|
|
+ }
|
|
|
|
+ wrapper.eq(LogisticsInfos::getCode, dto.getKeyword());
|
|
|
|
+ wrapper.orderByDesc("li", LogisticsInfos::getId);
|
|
|
|
+ Page<LogisticsInfosVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
|
+ List<LogisticsInfosVo> records = page.getRecords();
|
|
|
|
+ //赋值物流公司名字
|
|
|
|
+ List<String> codes = records.stream().map(LogisticsInfosVo::getCode).collect(Collectors.toList());
|
|
|
|
+ if (ObjectUtil.isEmpty(codes)) {
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+ List<CompanyInfo> list = companyInfoService.list(q -> q.in(CompanyInfo::getCode, codes));
|
|
|
|
+ if (ObjectUtil.isNotEmpty(list)) {
|
|
|
|
+ Map<String, String> companyMap = list.stream().collect(Collectors.toMap(CompanyInfo::getCode, CompanyInfo::getName));
|
|
|
|
+ for (LogisticsInfosVo record : records) {
|
|
|
|
+ String name = companyMap.get(record.getLogisticsCompanyCode());
|
|
|
|
+ record.setLogisticsCompanyName(name);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public LogisticsInfosVo detail(Long id) {
|
|
|
|
+ LogisticsInfos LogisticsInfos = this.getById(id);
|
|
|
|
+ LogisticsInfosVo result = BeanUtil.toBean(LogisticsInfos, LogisticsInfosVo.class);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @Override
|
|
|
|
+ public void add(LogisticsInfosDto logisticsInfosDto) {
|
|
|
|
+ this.save(logisticsInfosDto);
|
|
|
|
+ LogisticsDetails logisticsDetails = new LogisticsDetails();
|
|
|
|
+ logisticsDetails.setLogisticsInfoId(logisticsInfosDto.getId());
|
|
|
|
+ logisticsDetails.setRemark(logisticsInfosDto.getRemark());
|
|
|
|
+ logisticsDetailsService.save(logisticsDetails);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void edit(LogisticsInfosDto logisticsInfosDto) {
|
|
|
|
+ this.updateById(logisticsInfosDto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void delete(Long id) {
|
|
|
|
+ this.removeById(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public KD100Result getLogistics(Long id) {
|
|
|
|
+ LogisticsInfos logisticsInfo = this.getById(id);
|
|
|
|
+ Assert.notEmpty(logisticsInfo, "没有找到物流信息");
|
|
|
|
+ return KD100Util.queryTrack(logisticsInfo.getLogisticsCompanyCode(), logisticsInfo.getCode());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void dataInfoEdit(Long id) {
|
|
|
|
+ LogisticsInfos logisticsInfo = getById(id);
|
|
|
|
+ Assert.notEmpty(logisticsInfo, "没有找到物流信息");
|
|
|
|
+ KD100Result kd100Result = KD100Util.queryTrack(logisticsInfo.getLogisticsCompanyCode(), logisticsInfo.getCode());
|
|
|
|
+ Integer state = kd100Result.getState();
|
|
|
|
+ if (ObjectUtil.notEqual(state, logisticsInfo.getLogisticsStatus())) {
|
|
|
|
+ logisticsInfo.setLogisticsStatus(state);
|
|
|
|
+ updateById(logisticsInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void arrivalNotice(LogisticsInfosVo entity) {
|
|
|
|
+ // 采购id
|
|
|
|
+ Long purchaseId = entity.getPurchaseId();
|
|
|
|
+ Assert.notEmpty(purchaseId, "采购id不能为空");
|
|
|
|
+
|
|
|
|
+ entity.setStatus(LogisticsConstant.Status.STATUS_1);
|
|
|
|
+ updateById(entity);
|
|
|
|
+
|
|
|
|
+ Purchase purchase = new Purchase();
|
|
|
|
+ purchase.setId(purchaseId);
|
|
|
|
+ purchase.setArrivalStatus(10);//设置部分到货
|
|
|
|
+ purchaseService.updateById(purchase);
|
|
|
|
+
|
|
|
|
+ //物流到货通知
|
|
|
|
+ Assert.notEmpty(entity.getId(), "物流id不能为空");
|
|
|
|
+ LogisticsInfos logisticsInfo = new LogisticsInfos();
|
|
|
|
+ logisticsInfo.setId(entity.getId());
|
|
|
|
+ logisticsInfo.setLogisticsStatus(15);
|
|
|
|
+ updateById(logisticsInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|