Commit a1d4936a authored by wei's avatar wei 🎱

供方预警列表导出

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