提交 a5e86c2f authored 作者: 刘海泉's avatar 刘海泉

提交履约进度表相关接口

上级 3270b245
package com.clx.performance.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
import java.util.Optional;
public enum PerformanceProgressTabEnum {
;
//1:进行中的线路(不分页) 2:已结束线路 3:全部线路
@Getter
@AllArgsConstructor
public enum Type {
IN_PROCESS(1, "进行中的线路"),
END(2, "已结束线路"),
ALL(3, "全部线路"),
;
private final Integer code;
private final String name;
public static Optional<Type> getByCode(Integer code) {
return Arrays.stream(values()).filter(e -> e.code.equals(code)).findFirst();
}
public static String getMsgByCode(int code) {
return getByCode(code).map(Type::getName).orElse(null);
}
}
}
package com.clx.performance.dao; package com.clx.performance.dao;
import com.msl.common.dao.BaseDao; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.mapper.PerformanceProgressMapper; import com.clx.performance.mapper.PerformanceProgressMapper;
import com.clx.performance.model.PerformanceProgress; import com.clx.performance.model.PerformanceProgress;
import com.clx.performance.param.pc.carrier.PagePerformanceProgress;
import com.msl.common.dao.BaseDao;
import java.util.List;
/** /**
* @author kavin * @author kavin
...@@ -10,4 +14,5 @@ import com.clx.performance.model.PerformanceProgress; ...@@ -10,4 +14,5 @@ import com.clx.performance.model.PerformanceProgress;
* Time 16:02 * Time 16:02
*/ */
public interface PerformanceProgressDao extends BaseDao<PerformanceProgressMapper, PerformanceProgress, Integer> { public interface PerformanceProgressDao extends BaseDao<PerformanceProgressMapper, PerformanceProgress, Integer> {
IPage<PerformanceProgress> pagePerformanceProgress(List<Integer> statusList, PagePerformanceProgress param);
} }
package com.clx.performance.dao.impl; package com.clx.performance.dao.impl;
import com.msl.common.dao.impl.BaseDaoImpl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clx.performance.dao.PerformanceProgressDao; import com.clx.performance.dao.PerformanceProgressDao;
import com.clx.performance.mapper.PerformanceProgressMapper; import com.clx.performance.mapper.PerformanceProgressMapper;
import com.clx.performance.model.PerformanceProgress; import com.clx.performance.model.PerformanceProgress;
import com.clx.performance.param.pc.carrier.PagePerformanceProgress;
import com.msl.common.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
/** /**
* @author kavin * @author kavin
* Date 2024-07-12 * Date 2024-07-12
...@@ -13,4 +19,13 @@ import org.springframework.stereotype.Repository; ...@@ -13,4 +19,13 @@ import org.springframework.stereotype.Repository;
*/ */
@Repository @Repository
public class PerformanceProgressDaoImpl extends BaseDaoImpl<PerformanceProgressMapper, PerformanceProgress, Integer> implements PerformanceProgressDao { public class PerformanceProgressDaoImpl extends BaseDaoImpl<PerformanceProgressMapper, PerformanceProgress, Integer> implements PerformanceProgressDao {
@Override
public IPage<PerformanceProgress> pagePerformanceProgress(List<Integer> statusList, PagePerformanceProgress param){
Page<PerformanceProgress> page = Page.of(param.getPage(), param.getPageSize());
LambdaQueryWrapper<PerformanceProgress> query = new LambdaQueryWrapper<>();
query.in(PerformanceProgress :: getOrderStatus,statusList);
//最新接单的seq最大,所以这里升序排序
query.orderByAsc(PerformanceProgress :: getSeq);
return baseMapper.selectPage(page,query);
}
} }
package com.clx.performance.service; package com.clx.performance.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.model.PerformanceProgress;
import com.clx.performance.param.pc.carrier.PagePerformanceProgress; import com.clx.performance.param.pc.carrier.PagePerformanceProgress;
import com.clx.performance.vo.pc.PerformanceProgressVO; import com.clx.performance.vo.pc.PerformanceProgressVO;
...@@ -13,4 +14,9 @@ public interface PerformanceProgressService { ...@@ -13,4 +14,9 @@ public interface PerformanceProgressService {
IPage<PerformanceProgressVO> pagePerformanceProgress(PagePerformanceProgress param); IPage<PerformanceProgressVO> pagePerformanceProgress(PagePerformanceProgress param);
void updateAdjustOrder(Integer adjustOrderOneId, Integer adjustOrderTwoId); void updateAdjustOrder(Integer adjustOrderOneId, Integer adjustOrderTwoId);
void saveOrUpdatePerformanceProgress(PerformanceProgress item);
} }
package com.clx.performance.service.impl; package com.clx.performance.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clx.performance.dao.PerformanceProgressDao;
import com.clx.performance.enums.OrderEnum;
import com.clx.performance.enums.PerformanceProgressTabEnum;
import com.clx.performance.enums.ResultEnum;
import com.clx.performance.model.PerformanceProgress;
import com.clx.performance.param.pc.carrier.PagePerformanceProgress; import com.clx.performance.param.pc.carrier.PagePerformanceProgress;
import com.clx.performance.service.PerformanceProgressService; import com.clx.performance.service.PerformanceProgressService;
import com.clx.performance.struct.PerformanceProgressStruct;
import com.clx.performance.vo.pc.PerformanceProgressVO; import com.clx.performance.vo.pc.PerformanceProgressVO;
import com.msl.common.base.Optional;
import com.msl.common.exception.ServiceSystemException;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/** /**
* @author kavin * @author kavin
* Date 2024-07-12 * Date 2024-07-12
...@@ -14,14 +30,120 @@ import org.springframework.stereotype.Service; ...@@ -14,14 +30,120 @@ import org.springframework.stereotype.Service;
*/ */
@Service @Service
@Slf4j @Slf4j
@AllArgsConstructor
public class PerformanceProgressServiceImpl implements PerformanceProgressService { public class PerformanceProgressServiceImpl implements PerformanceProgressService {
private final PerformanceProgressDao performanceProgressDao;
private final PerformanceProgressStruct performanceProgressStruct;
public static List<Integer> inProcessStatusList;
public static List<Integer> endStatusList ;
public static List<Integer> allStatusList ;
static {
inProcessStatusList = Arrays.asList(
OrderEnum.Status.PLATFORM_UNDERTAKING.getCode(),
OrderEnum.Status.SUSPEND.getCode(),
OrderEnum.Status.ON_ORDER.getCode(),
OrderEnum.Status.IN_TRANSIT.getCode());
endStatusList = Arrays.asList(
OrderEnum.Status.SUCCESS.getCode(),
OrderEnum.Status.COMPLETED.getCode());
allStatusList = Arrays.asList(
OrderEnum.Status.PLATFORM_UNDERTAKING.getCode(),
OrderEnum.Status.SUSPEND.getCode(),
OrderEnum.Status.ON_ORDER.getCode(),
OrderEnum.Status.IN_TRANSIT.getCode(),
OrderEnum.Status.SUCCESS.getCode(),
OrderEnum.Status.COMPLETED.getCode());
}
@Override @Override
public IPage<PerformanceProgressVO> pagePerformanceProgress(PagePerformanceProgress param) { public IPage<PerformanceProgressVO> pagePerformanceProgress(PagePerformanceProgress param) {
return null;
IPage<PerformanceProgress> page = new Page<>();
IPage<PerformanceProgressVO> returnPage = new Page<>();
if(Objects.equals(param.getTab(), PerformanceProgressTabEnum.Type.IN_PROCESS.getCode())){
param.setPage(1);
param.setPageSize(10000);
page = performanceProgressDao.pagePerformanceProgress(inProcessStatusList,param);
}else if(Objects.equals(param.getTab(), PerformanceProgressTabEnum.Type.END.getCode())){
page = performanceProgressDao.pagePerformanceProgress(endStatusList,param);
}else if(Objects.equals(param.getTab(), PerformanceProgressTabEnum.Type.ALL.getCode())){
page = performanceProgressDao.pagePerformanceProgress(allStatusList,param);
}
if(CollectionUtils.isEmpty(page.getRecords())){
return returnPage;
}
List<PerformanceProgressVO> records = performanceProgressStruct.convertList(page.getRecords());
returnPage.setPages(page.getPages());
returnPage.setTotal(page.getTotal());
returnPage.setRecords(records);
//如果查询的是 已结束线路,则不需要计算,直接返回
if(Objects.equals(param.getTab(), PerformanceProgressTabEnum.Type.END.getCode())){
return returnPage;
}
returnPage.getRecords().forEach(item ->{
//TODO 进行订单运费预估调用 开发批量调用的接口。 订单完结完成后把运费预估查询出来的数据存入到数据库,后续不再实时查询
if(inProcessStatusList.contains(item.getOrderStatus())){ //进行中的订单线路
}
});
return returnPage;
} }
@Override @Override
public void updateAdjustOrder(Integer adjustOrderOneId, Integer adjustOrderTwoId) { public void updateAdjustOrder(Integer adjustOrderOneId, Integer adjustOrderTwoId) {
Optional<PerformanceProgress> one = performanceProgressDao.getEntityByKey(adjustOrderOneId);
Optional<PerformanceProgress> two = performanceProgressDao.getEntityByKey(adjustOrderTwoId);
if(!one.isPresent() || !two.isPresent()){
throw new ServiceSystemException(ResultEnum.DATA_NOT_FIND);
}
PerformanceProgress updateOne = new PerformanceProgress();
updateOne.setId(one.get().getId());
updateOne.setSeq(two.get().getSeq());
PerformanceProgress updateTwo = new PerformanceProgress();
updateTwo.setId(two.get().getId());
updateTwo.setSeq(one.get().getSeq());
List<PerformanceProgress> list = new ArrayList<>();
list.add(updateOne);
list.add(updateTwo);
performanceProgressDao.updateBatchList(list);
}
//通过dts监听订单、货单、运单表进行更新履约进度表的数据
@Override
public void saveOrUpdatePerformanceProgress(PerformanceProgress item) {
Optional<PerformanceProgress> optional = performanceProgressDao.getOneByField(PerformanceProgress::getOrderNo,
item.getOrderNo());
if(optional.isPresent()){
item.setId(optional.get().getId());
performanceProgressDao.updateEntityByKey(item);
}else{
performanceProgressDao.saveEntity(item);
}
} }
} }
package com.clx.performance.struct;
import com.clx.performance.model.PerformanceProgress;
import com.clx.performance.vo.pc.PerformanceProgressVO;
import com.msl.common.utils.DateStructUtil;
import com.msl.common.utils.DateUtils;
import org.mapstruct.Mapper;
import java.util.List;
@Mapper(componentModel = "spring", uses = DateStructUtil.class, imports = {DateUtils.class})
public interface PerformanceProgressStruct {
List<PerformanceProgressVO> convertList(List<PerformanceProgress> records);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论