Commit a1d4936a authored by wei's avatar wei 🎱

供方预警列表导出

parent 628e1c4d
......@@ -13,6 +13,9 @@ import java.time.LocalDateTime;
*/
@Data
public class SupplierEarlyWarningVO implements Serializable {
private long id;
/**
* 供方编号
*/
......
......@@ -5,15 +5,13 @@ import com.yonde.dcs.plan.common.vo.ExtSupplierManageVO;
import com.yonde.dcs.plan.common.vo.SupplierEarlyWarningVO;
import com.yonde.dcs.plan.core.controller.shadow.ExtSupplierManageControllerShadow;
import com.yonde.dcs.plan.core.service.ExtSupplierManageService;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import com.yonde.dex.basedata.entity.api.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
......@@ -43,17 +41,17 @@ public class ExtSupplierManageController<V extends ExtSupplierManageVO, S extend
@ApiOperation("供方预警列表")
@PostMapping({"earlyWarning"})
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), "查询成功");
@RequestBody SearchQueryCondition searchQueryCondition) {
return ApiResult.ok(extSupplierManageService.earlyWarning(searchQueryCondition, warningDay), "查询成功");
}
@ApiOperation("导出供方预警列表")
@PostMapping(value = "/exportEarlyWarningData")
public void exportEarlyWarningData(@RequestParam("fileName") String fileName, @RequestParam("ids") List<Long> ids,
HttpServletResponse response) {
public void exportEarlyWarningData(@RequestParam("fileName") String fileName, HttpServletResponse response,
@RequestParam(value = "warningDay", defaultValue = "30") int warningDay,
@RequestBody SearchQueryCondition searchQueryCondition) {
try {
List<SupplierEarlyWarningVO> list = extSupplierManageService.exportEarlyWarningData(ids);
List<SupplierEarlyWarningVO> list = extSupplierManageService.exportEarlyWarningData(searchQueryCondition, warningDay);
EasyExcelUtils.exportData(fileName, response, list, SupplierEarlyWarningVO.class);
} catch (IOException e) {
throw new RuntimeException(e);
......
......@@ -3,6 +3,7 @@ package com.yonde.dcs.plan.core.service;
import com.yonde.dcs.plan.common.vo.ExtSupplierManageVO;
import com.yonde.dcs.plan.common.vo.SupplierEarlyWarningVO;
import com.yonde.dcs.plan.core.service.shadow.ExtSupplierManageServiceShadow;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import java.util.List;
......@@ -16,15 +17,7 @@ public interface ExtSupplierManageService<V extends ExtSupplierManageVO> extends
ExtSupplierManageVO startWorkflow(Long id);
/**
* 获取预警列表
*
* @param pageSize 每页大小
* @param pageNumber 第几页
* @param warningDay 预警天数
* @return
*/
List<SupplierEarlyWarningVO> earlyWarning(int pageSize, int pageNumber, int warningDay);
List<SupplierEarlyWarningVO> earlyWarning(SearchQueryCondition searchQueryCondition, int warningDay);
List<SupplierEarlyWarningVO> exportEarlyWarningData(List<Long> ids);
List<SupplierEarlyWarningVO> exportEarlyWarningData(SearchQueryCondition searchQueryCondition, int warningDay);
}
......@@ -10,7 +10,6 @@ import com.yonde.dcs.plan.core.service.ExtSupplierManageLinkService;
import com.yonde.dcs.plan.core.service.ExtSupplierManageService;
import com.yonde.dcs.plan.entity.po.ExtSupplierManage;
import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchItems;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.wfc.feign.api.WfcProcessFeign;
......@@ -21,7 +20,6 @@ import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
import java.util.stream.Collectors;
/**
* @description: ExtSupplierManage-ServiceImpl
......@@ -57,19 +55,10 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme
}
@Override
public List<SupplierEarlyWarningVO> earlyWarning(int pageSize, int pageNumber, int warningDay) {
public List<SupplierEarlyWarningVO> earlyWarning(SearchQueryCondition searchQueryCondition, 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());
}
List<ExtSupplierManageLinkVO> extSupplierManageLinkVOS = this.recursionSupplierManageLinks(searchQueryCondition, warningDate.toString());
for (ExtSupplierManageLinkVO extSupplierManageLinkVO : extSupplierManageLinkVOS) {
ExtSupplierManageVO source = extSupplierManageLinkVO.getSource();
ExtQualificationsVO target = extSupplierManageLinkVO.getTarget();
......@@ -79,8 +68,8 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme
}
@Override
public List<SupplierEarlyWarningVO> exportEarlyWarningData(List<Long> ids) {
return this.earlyWarning(0, 0, 30);
public List<SupplierEarlyWarningVO> exportEarlyWarningData(SearchQueryCondition searchQueryCondition, int warningDay) {
return earlyWarning(searchQueryCondition, warningDay);
}
private SupplierEarlyWarningVO buildSupplierEarlyWarningVO(ExtSupplierManageVO source, ExtQualificationsVO target) {
......@@ -89,19 +78,22 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme
supplierEarlyWarningVO.setQualificationsContent(target.getQualificationsContent());
supplierEarlyWarningVO.setCertificateNumber(target.getCertificateNumber());
supplierEarlyWarningVO.setCertificateTime(target.getCertificateTime());
supplierEarlyWarningVO.setId(target.getId());
return supplierEarlyWarningVO;
}
private List<ExtSupplierManageLinkVO> recursionSupplierManageLinks(String warningDate) {
SearchQueryCondition condition = SearchQueryCondition.builder().searchItems(
private List<ExtSupplierManageLinkVO> recursionSupplierManageLinks(SearchQueryCondition searchQueryCondition, String warningDate) {
/*SearchQueryCondition condition = SearchQueryCondition.builder().searchItems(
SearchItems.of(
SearchItems.BooleanOperator.AND,
new SearchItem("target.certificateTime", SearchItem.Operator.GT, warningDate, null)
)
).openProp(SearchQueryCondition.builder().name("target").build()
).openProp(SearchQueryCondition.builder().name("source").build()).build();
List<ExtSupplierManageLinkVO> content = extSupplierManageLinkService.findRecursion(condition).getContent();
).openProp(SearchQueryCondition.builder().name("source").build()).build();*/
SearchItem searchItem = new SearchItem("target.certificateTime", SearchItem.Operator.GT, warningDate);
searchQueryCondition.getSearchItems().getItems().add(searchItem);
List<ExtSupplierManageLinkVO> content = extSupplierManageLinkService.findRecursion(searchQueryCondition).getContent();
return content;
}
}
......
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