Commit 2a5fba8f authored by wei's avatar wei 🎱

供方预警接口

parent c3239d70
...@@ -35,7 +35,11 @@ public class ExtSupplierManageController<V extends ExtSupplierManageVO, S extend ...@@ -35,7 +35,11 @@ public class ExtSupplierManageController<V extends ExtSupplierManageVO, S extend
return ApiResult.ok(extSupplierManageService.startWorkflow(id),"操作完成"); return ApiResult.ok(extSupplierManageService.startWorkflow(id),"操作完成");
} }
@ApiOperation("供方预警列表")
@PostMapping({"earlyWarning"})
public ApiResult earlyWarning(@RequestParam("warningDay") Integer warningDay){
return ApiResult.ok(extSupplierManageService.earlyWarning(warningDay),"查询成功");
}
} }
package com.yonde.dcs.plan.core.service; 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.core.service.shadow.ExtSupplierManageServiceShadow; import com.yonde.dcs.plan.core.service.shadow.ExtSupplierManageServiceShadow;
import java.util.List;
/** /**
* @description: ExtSupplierManage-service * @description: ExtSupplierManage-service
* @author: dexadmin * @author: dexadmin
...@@ -13,4 +16,5 @@ public interface ExtSupplierManageService<V extends ExtSupplierManageVO> extends ...@@ -13,4 +16,5 @@ public interface ExtSupplierManageService<V extends ExtSupplierManageVO> extends
ExtSupplierManageVO startWorkflow(Long id); ExtSupplierManageVO startWorkflow(Long id);
List<SupplierEarlyWarningVO> earlyWarning(Integer warningDay);
} }
package com.yonde.dcs.plan.core.service.impl; package com.yonde.dcs.plan.core.service.impl;
import com.google.common.collect.Lists;
import com.yonde.dcs.plan.common.vo.ExtQualificationsVO;
import com.yonde.dcs.plan.common.vo.ExtSupplierManageLinkVO;
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.core.repository.ExtSupplierManageRepository; import com.yonde.dcs.plan.core.repository.ExtSupplierManageRepository;
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.SearchItems;
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.lang3.ObjectUtils;
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.util.List;
/** /**
* @description: ExtSupplierManage-ServiceImpl * @description: ExtSupplierManage-ServiceImpl
* @author: dexadmin * @author: dexadmin
...@@ -27,9 +40,12 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme ...@@ -27,9 +40,12 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme
@Autowired @Autowired
ExtSupplierManageRepository<ExtSupplierManage> extSupplierManageRepository; ExtSupplierManageRepository<ExtSupplierManage> extSupplierManageRepository;
@Autowired
private ExtSupplierManageLinkService extSupplierManageLinkService;
@Override @Override
public ExtSupplierManageVO startWorkflow(Long id) { public ExtSupplierManageVO startWorkflow(Long id) {
ExtSupplierManageVO extSupplierManageVO= get(id); ExtSupplierManageVO extSupplierManageVO = get(id);
if (extSupplierManageVO == null) { if (extSupplierManageVO == null) {
throw new DxBusinessException("500", "获取不到对象"); throw new DxBusinessException("500", "获取不到对象");
} }
...@@ -39,6 +55,47 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme ...@@ -39,6 +55,47 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme
wfcProcessFeign.startProcessByKey("supplierQualificationReviewWF", extSupplierManageVO); wfcProcessFeign.startProcessByKey("supplierQualificationReviewWF", extSupplierManageVO);
return this.changeStatus(extSupplierManageVO.getId(), "submitReviewing", true); return this.changeStatus(extSupplierManageVO.getId(), "submitReviewing", true);
} }
@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);
}
List<SupplierEarlyWarningVO> list = Lists.newArrayList();
List<ExtSupplierManageLinkVO> extSupplierManageLinkVOS = this.recursionSupplierManageLinks(warningDate.toString());
for (ExtSupplierManageLinkVO extSupplierManageLinkVO : extSupplierManageLinkVOS) {
ExtSupplierManageVO source = extSupplierManageLinkVO.getSource();
ExtQualificationsVO target = extSupplierManageLinkVO.getTarget();
list.add(this.buildSupplierEarlyWarningVO(source, target));
}
return list;
}
private SupplierEarlyWarningVO buildSupplierEarlyWarningVO(ExtSupplierManageVO source, ExtQualificationsVO target) {
SupplierEarlyWarningVO supplierEarlyWarningVO = new SupplierEarlyWarningVO();
BeanUtils.copyProperties(source, supplierEarlyWarningVO);
supplierEarlyWarningVO.setQualificationsContent(target.getQualificationsContent());
supplierEarlyWarningVO.setCertificateNumber(target.getCertificateNumber());
supplierEarlyWarningVO.setCertificateTime(target.getCertificateTime());
return supplierEarlyWarningVO;
}
private List<ExtSupplierManageLinkVO> recursionSupplierManageLinks(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();
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