Commit 628e1c4d authored by wei's avatar wei 🎱

供方预警列表分页

parent 7dc713b3
......@@ -42,8 +42,10 @@ public class ExtSupplierManageController<V extends ExtSupplierManageVO, S extend
@ApiOperation("供方预警列表")
@PostMapping({"earlyWarning"})
public ApiResult earlyWarning(@RequestParam("warningDay") Integer warningDay) {
return ApiResult.ok(extSupplierManageService.earlyWarning(warningDay), "查询成功");
public ApiResult earlyWarning(@RequestParam(value = "warningDay", defaultValue = "30") int warningDay,
@RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
@RequestParam(value = "pageNumber", defaultValue = "1") int pageNumber) {
return ApiResult.ok(extSupplierManageService.earlyWarning(pageSize, pageNumber, warningDay), "查询成功");
}
@ApiOperation("导出供方预警列表")
......
......@@ -16,7 +16,15 @@ public interface ExtSupplierManageService<V extends ExtSupplierManageVO> extends
ExtSupplierManageVO startWorkflow(Long id);
List<SupplierEarlyWarningVO> earlyWarning(Integer warningDay);
/**
* 获取预警列表
*
* @param pageSize 每页大小
* @param pageNumber 第几页
* @param warningDay 预警天数
* @return
*/
List<SupplierEarlyWarningVO> earlyWarning(int pageSize, int pageNumber, int warningDay);
List<SupplierEarlyWarningVO> exportEarlyWarningData(List<Long> ids);
}
......@@ -15,14 +15,13 @@ import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.wfc.feign.api.WfcProcessFeign;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
import java.util.stream.Collectors;
/**
* @description: ExtSupplierManage-ServiceImpl
......@@ -58,16 +57,19 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme
}
@Override
public List<SupplierEarlyWarningVO> earlyWarning(Integer warningDay) {
LocalDate warningDate = LocalDate.now();
// 默认减30天
if (ObjectUtils.isEmpty(warningDay)) {
warningDate = warningDate.minusDays(30);
} else {
warningDate = warningDate.minusDays(warningDay);
}
public List<SupplierEarlyWarningVO> earlyWarning(int pageSize, int pageNumber, int warningDay) {
List<SupplierEarlyWarningVO> list = Lists.newArrayList();
LocalDate warningDate = LocalDate.now().minusDays(warningDay);
List<ExtSupplierManageLinkVO> extSupplierManageLinkVOS = this.recursionSupplierManageLinks(warningDate.toString());
// 分页
if (pageSize > 0 && pageNumber > 0) {
int fromIndex = (pageNumber - 1) * pageSize;
//int toIndex = fromIndex + pageSize;
if (fromIndex >= extSupplierManageLinkVOS.size()) {
return list;
}
extSupplierManageLinkVOS = extSupplierManageLinkVOS.stream().skip(fromIndex).limit(pageSize).collect(Collectors.toList());
}
for (ExtSupplierManageLinkVO extSupplierManageLinkVO : extSupplierManageLinkVOS) {
ExtSupplierManageVO source = extSupplierManageLinkVO.getSource();
ExtQualificationsVO target = extSupplierManageLinkVO.getTarget();
......@@ -78,7 +80,7 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme
@Override
public List<SupplierEarlyWarningVO> exportEarlyWarningData(List<Long> ids) {
return this.earlyWarning(30);
return this.earlyWarning(0, 0, 30);
}
private SupplierEarlyWarningVO buildSupplierEarlyWarningVO(ExtSupplierManageVO source, ExtQualificationsVO target) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment