Commit 628e1c4d authored by wei's avatar wei 🎱

供方预警列表分页

parent 7dc713b3
...@@ -42,8 +42,10 @@ public class ExtSupplierManageController<V extends ExtSupplierManageVO, S extend ...@@ -42,8 +42,10 @@ public class ExtSupplierManageController<V extends ExtSupplierManageVO, S extend
@ApiOperation("供方预警列表") @ApiOperation("供方预警列表")
@PostMapping({"earlyWarning"}) @PostMapping({"earlyWarning"})
public ApiResult earlyWarning(@RequestParam("warningDay") Integer warningDay) { public ApiResult earlyWarning(@RequestParam(value = "warningDay", defaultValue = "30") int warningDay,
return ApiResult.ok(extSupplierManageService.earlyWarning(warningDay), "查询成功"); @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
@RequestParam(value = "pageNumber", defaultValue = "1") int pageNumber) {
return ApiResult.ok(extSupplierManageService.earlyWarning(pageSize, pageNumber, warningDay), "查询成功");
} }
@ApiOperation("导出供方预警列表") @ApiOperation("导出供方预警列表")
......
...@@ -16,7 +16,15 @@ public interface ExtSupplierManageService<V extends ExtSupplierManageVO> extends ...@@ -16,7 +16,15 @@ public interface ExtSupplierManageService<V extends ExtSupplierManageVO> extends
ExtSupplierManageVO startWorkflow(Long id); 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); List<SupplierEarlyWarningVO> exportEarlyWarningData(List<Long> ids);
} }
...@@ -15,14 +15,13 @@ import com.yonde.dex.basedata.data.search.SearchQueryCondition; ...@@ -15,14 +15,13 @@ import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import com.yonde.dex.basedata.exception.DxBusinessException; import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.wfc.feign.api.WfcProcessFeign; import com.yonde.dex.wfc.feign.api.WfcProcessFeign;
import lombok.extern.slf4j.Slf4j; 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.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @description: ExtSupplierManage-ServiceImpl * @description: ExtSupplierManage-ServiceImpl
...@@ -58,16 +57,19 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme ...@@ -58,16 +57,19 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme
} }
@Override @Override
public List<SupplierEarlyWarningVO> earlyWarning(Integer warningDay) { public List<SupplierEarlyWarningVO> earlyWarning(int pageSize, int pageNumber, int warningDay) {
LocalDate warningDate = LocalDate.now();
// 默认减30天
if (ObjectUtils.isEmpty(warningDay)) {
warningDate = warningDate.minusDays(30);
} else {
warningDate = warningDate.minusDays(warningDay);
}
List<SupplierEarlyWarningVO> list = Lists.newArrayList(); List<SupplierEarlyWarningVO> list = Lists.newArrayList();
LocalDate warningDate = LocalDate.now().minusDays(warningDay);
List<ExtSupplierManageLinkVO> extSupplierManageLinkVOS = this.recursionSupplierManageLinks(warningDate.toString()); 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) { for (ExtSupplierManageLinkVO extSupplierManageLinkVO : extSupplierManageLinkVOS) {
ExtSupplierManageVO source = extSupplierManageLinkVO.getSource(); ExtSupplierManageVO source = extSupplierManageLinkVO.getSource();
ExtQualificationsVO target = extSupplierManageLinkVO.getTarget(); ExtQualificationsVO target = extSupplierManageLinkVO.getTarget();
...@@ -78,7 +80,7 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme ...@@ -78,7 +80,7 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme
@Override @Override
public List<SupplierEarlyWarningVO> exportEarlyWarningData(List<Long> ids) { public List<SupplierEarlyWarningVO> exportEarlyWarningData(List<Long> ids) {
return this.earlyWarning(30); return this.earlyWarning(0, 0, 30);
} }
private SupplierEarlyWarningVO buildSupplierEarlyWarningVO(ExtSupplierManageVO source, ExtQualificationsVO target) { 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