|
@@ -9,18 +9,18 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
|
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
|
|
import com.persagy.dmp.common.constant.ValidEnum;
|
|
|
import com.persagy.dmp.common.model.entity.BaseEntity;
|
|
|
import com.persagy.dmp.define.entity.ObjectTypeDefine;
|
|
|
+import com.persagy.dmp.delivery.dto.DeliveryPlanDTO;
|
|
|
import com.persagy.dmp.delivery.dto.ObjectTypeCollectDTO;
|
|
|
-import com.persagy.dmp.delivery.dto.boss.DeliveryOrderDTO;
|
|
|
import com.persagy.dmp.delivery.entity.BossBdtpTypeRel;
|
|
|
import com.persagy.dmp.delivery.entity.ObjectInfoCollect;
|
|
|
import com.persagy.dmp.delivery.entity.ObjectTypeCollect;
|
|
|
import com.persagy.dmp.delivery.entity.RelationDefineCollect;
|
|
|
import com.persagy.dmp.rwd.define.service.IObjectTypeService;
|
|
|
import com.persagy.dmp.rwd.delivery.dao.ObjectTypeCollectMapper;
|
|
|
-import com.persagy.dmp.rwd.delivery.service.IBossBdtpTypeRelService;
|
|
|
import com.persagy.dmp.rwd.delivery.service.IObjectInfoCollectService;
|
|
|
import com.persagy.dmp.rwd.delivery.service.IObjectTypeCollectService;
|
|
|
import com.persagy.dmp.rwd.delivery.service.IRelationDefineCollectService;
|
|
@@ -49,9 +49,6 @@ public class ObjectTypeCollectServiceImpl extends ServiceImpl<ObjectTypeCollectM
|
|
|
private IObjectTypeService objectTypeService;
|
|
|
|
|
|
@Autowired
|
|
|
- private IBossBdtpTypeRelService bossBdtpTypeRelService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
private IObjectTypeCollectService objectTypeCollectService;
|
|
|
|
|
|
@Autowired
|
|
@@ -81,108 +78,28 @@ public class ObjectTypeCollectServiceImpl extends ServiceImpl<ObjectTypeCollectM
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 设置项目交付范围信息
|
|
|
+ * 生成项目交付范围信息
|
|
|
* @param voList
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<DeliveryOrderDTO> settingProjectDelivery(List<DeliveryOrderDTO> voList) throws Exception {
|
|
|
- //1. 查询商品映射关系
|
|
|
- Map<String, Set<String>> typeRelMap = queryBossBdtpTypeRel();
|
|
|
- if(CollUtil.isEmpty(typeRelMap)){
|
|
|
- return voList;
|
|
|
- }
|
|
|
- //2. 查询BDTP标准交付范围-对象类型
|
|
|
+ public List<DeliveryPlanDTO> createProjectDelivery(List<DeliveryPlanDTO> voList) throws Exception {
|
|
|
+ //1. 查询BDTP标准交付范围-对象类型
|
|
|
Map<String, ObjectTypeCollect> typeCollectMap = queryBdtpObjectTypeCollect();
|
|
|
- //3. 查询BDTP标准交付范围-信息点
|
|
|
+ //2. 查询BDTP标准交付范围-信息点
|
|
|
Map<String, List<ObjectInfoCollect>> infoCollectMap = queryBdtpObjectInfoCollect();
|
|
|
- //4. 查询BDTP标准交付范围- 关系
|
|
|
- Map<String, List<RelationDefineCollect>> relationCollectMap = queryBdtpObjectRelCollect();
|
|
|
-
|
|
|
- //5. 初始化项目交付范围
|
|
|
- for (DeliveryOrderDTO deliveryOrderDTO : voList) {
|
|
|
- ArrayNode goodsCode = deliveryOrderDTO.getGoodsCode();
|
|
|
- if(CollUtil.isEmpty(goodsCode)){
|
|
|
- continue;
|
|
|
- }
|
|
|
- //获取项目需交付类型编码
|
|
|
- Set<String> allTypeCodes = new HashSet<>();
|
|
|
- goodsCode.forEach(item->{
|
|
|
- Set<String> typecodes = typeRelMap.get(item);
|
|
|
- if(CollUtil.isEmpty(typecodes)){
|
|
|
- allTypeCodes.addAll(typecodes);
|
|
|
- }
|
|
|
- });
|
|
|
- //初始化对象类型交付范围
|
|
|
- initDelivertyObjectType(deliveryOrderDTO,allTypeCodes,typeCollectMap);
|
|
|
- //初始化信息点交付范围
|
|
|
- initDelivertyObjectInfo(deliveryOrderDTO,allTypeCodes,infoCollectMap);
|
|
|
- //初始化关系交付范围
|
|
|
- //存储原订单信息
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
+ //3. 查询BDTP标准交付范围- 关系
|
|
|
+ List<RelationDefineCollect> relationCollectList = queryBdtpObjectRelCollect();
|
|
|
+ //4. 初始化项目交付范围
|
|
|
|
|
|
- /**
|
|
|
- * 初始化对象类型交付范围
|
|
|
- * @param deliveryOrderDTO
|
|
|
- * @param allTypeCodes
|
|
|
- */
|
|
|
- private void initDelivertyObjectType(DeliveryOrderDTO deliveryOrderDTO,Set<String> allTypeCodes,Map<String, ObjectTypeCollect> typeCollectMap) throws Exception{
|
|
|
- if(CollUtil.isEmpty(allTypeCodes) || CollUtil.isEmpty(typeCollectMap)){
|
|
|
- return;
|
|
|
- }
|
|
|
- //组装类型交付信息
|
|
|
- List<ObjectTypeCollect> content = new ArrayList<>();
|
|
|
- for (String typeCode : allTypeCodes) {
|
|
|
- ObjectTypeCollect typeCollect = typeCollectMap.get(typeCode);
|
|
|
- if(typeCollect == null){
|
|
|
- log.info("BOSS项目范围交付:交付类型不在BDTP标准交付范围内:{}"+typeCode);
|
|
|
- continue;
|
|
|
- }
|
|
|
- typeCollect.setProjectId(deliveryOrderDTO.getProjectId());
|
|
|
- typeCollect.setIsDelivery(1);
|
|
|
- content.add(typeCollect);
|
|
|
- }
|
|
|
- if(CollUtil.isEmpty(content)){
|
|
|
- log.info("BOSS项目范围交付:无类型交付信息");
|
|
|
- return;
|
|
|
- }
|
|
|
- //类型信息交付
|
|
|
- objectTypeCollectService.insert(content);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 初始化对象类型交付范围
|
|
|
- * @param deliveryOrderDTO
|
|
|
- * @param allTypeCodes
|
|
|
- */
|
|
|
- private void initDelivertyObjectInfo(DeliveryOrderDTO deliveryOrderDTO,Set<String> allTypeCodes,Map<String, List<ObjectInfoCollect>> infoCollectMap) throws Exception{
|
|
|
- if(CollUtil.isEmpty(allTypeCodes) || CollUtil.isEmpty(infoCollectMap)){
|
|
|
- return;
|
|
|
- }
|
|
|
- //组装信息点交付信息
|
|
|
- List<ObjectInfoCollect> content = new ArrayList<>();
|
|
|
- for (String typeCode : allTypeCodes) {
|
|
|
- List<ObjectInfoCollect> infoCollectList = infoCollectMap.get(typeCode);
|
|
|
- if(CollUtil.isEmpty(infoCollectList)){
|
|
|
- log.info("该类型下无需交付的信息点:{}"+typeCode);
|
|
|
- continue;
|
|
|
- }
|
|
|
- infoCollectList.forEach(item->{
|
|
|
- item.setProjectId(deliveryOrderDTO.getProjectId());
|
|
|
- item.setIsDelivery(true);
|
|
|
- content.add(item);
|
|
|
- });
|
|
|
- }
|
|
|
- if(CollUtil.isEmpty(content)){
|
|
|
- log.info("BOSS项目范围交付:无信息点交付信息");
|
|
|
- return;
|
|
|
- }
|
|
|
- //类型信息交付
|
|
|
- objectInfoCollectService.insert(content);
|
|
|
+ //5.1 初始化对象类型交付范围
|
|
|
+ initDelivertyObjectType(voList,typeCollectMap);
|
|
|
+ //5.2 初始化信息点交付范围
|
|
|
+ initDelivertyObjectInfo(voList,infoCollectMap);
|
|
|
+ //5.3 初始化关系交付范围
|
|
|
+ initDeliveryGraphRel(voList,relationCollectList);
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -320,19 +237,6 @@ public class ObjectTypeCollectServiceImpl extends ServiceImpl<ObjectTypeCollectM
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 查询商品类型映射关系
|
|
|
- * @return
|
|
|
- */
|
|
|
- private Map<String,Set<String>> queryBossBdtpTypeRel(){
|
|
|
- List<BossBdtpTypeRel> typeRelList = bossBdtpTypeRelService.queryByCondition(new QueryWrapper<>());
|
|
|
- if(CollUtil.isEmpty(typeRelList)){
|
|
|
- return new HashMap<>();
|
|
|
- }
|
|
|
- return typeRelList.stream().collect(Collectors.groupingBy(BossBdtpTypeRel::getGoodCode,
|
|
|
- Collectors.mapping(BossBdtpTypeRel::getTypeCode, Collectors.toSet())));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 查询BDTP标准交付范围-对象类型
|
|
|
*/
|
|
|
private Map<String,ObjectTypeCollect> queryBdtpObjectTypeCollect(){
|
|
@@ -367,28 +271,126 @@ public class ObjectTypeCollectServiceImpl extends ServiceImpl<ObjectTypeCollectM
|
|
|
/**
|
|
|
* 查询BDTP标准交付范围-关系
|
|
|
*/
|
|
|
- private Map<String,List<RelationDefineCollect>> queryBdtpObjectRelCollect(){
|
|
|
+ private List<RelationDefineCollect> queryBdtpObjectRelCollect(){
|
|
|
LambdaQueryWrapper<RelationDefineCollect> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(RelationDefineCollect::getGroupCode,"0");
|
|
|
wrapper.eq(RelationDefineCollect::getProjectId,"0");
|
|
|
wrapper.eq(RelationDefineCollect::getValid,ValidEnum.TRUE.getType());
|
|
|
- List<RelationDefineCollect> relationCollects = relationDefineCollectService.queryByCondition(wrapper);
|
|
|
- if(CollUtil.isEmpty(relationCollects)){
|
|
|
- return new HashMap<>();
|
|
|
- }/*
|
|
|
+ return relationDefineCollectService.queryByCondition(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化对象类型交付范围
|
|
|
+ * @param deliverPlanList
|
|
|
+ */
|
|
|
+ private void initDelivertyObjectType(List<DeliveryPlanDTO> deliverPlanList,Map<String, ObjectTypeCollect> typeCollectMap) throws Exception{
|
|
|
+ if(CollUtil.isEmpty(deliverPlanList) || CollUtil.isEmpty(typeCollectMap)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //组装类型交付信息
|
|
|
+ List<ObjectTypeCollect> content = new ArrayList<>();
|
|
|
+ for (DeliveryPlanDTO deliveryPlan : deliverPlanList) {
|
|
|
+ String classCode = deliveryPlan.getClassCode();
|
|
|
+ ObjectTypeCollect typeCollect = typeCollectMap.get(classCode);
|
|
|
+ if(typeCollect == null){
|
|
|
+ log.info("BOSS项目范围交付:交付类型不在BDTP标准交付范围内:{}"+classCode);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ typeCollect.setProjectId(deliveryPlan.getProjectId());
|
|
|
+ typeCollect.setIsDelivery(1);
|
|
|
+ content.add(typeCollect);
|
|
|
+ }
|
|
|
+ if(CollUtil.isEmpty(content)){
|
|
|
+ log.info("BOSS项目范围交付:无类型交付信息");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //类型信息交付
|
|
|
+ objectTypeCollectService.insert(content);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化对象类型交付范围
|
|
|
+ * @param deliverPlanList
|
|
|
+ */
|
|
|
+ private void initDelivertyObjectInfo(List<DeliveryPlanDTO> deliverPlanList,Map<String, List<ObjectInfoCollect>> infoCollectMap) throws Exception{
|
|
|
+ if(CollUtil.isEmpty(deliverPlanList) || CollUtil.isEmpty(infoCollectMap)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //组装信息点交付信息
|
|
|
+ List<ObjectInfoCollect> content = new ArrayList<>();
|
|
|
+ for (DeliveryPlanDTO deliveryPlan : deliverPlanList) {
|
|
|
+ String classCode = deliveryPlan.getClassCode();
|
|
|
+ List<ObjectInfoCollect> infoCollectList = infoCollectMap.get(classCode);
|
|
|
+ if(CollUtil.isEmpty(infoCollectList)){
|
|
|
+ log.info("该类型下无需交付的信息点:{}"+classCode);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ infoCollectList.forEach(item->{
|
|
|
+ item.setProjectId(deliveryPlan.getProjectId());
|
|
|
+ item.setIsDelivery(true);
|
|
|
+ content.add(item);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(CollUtil.isEmpty(content)){
|
|
|
+ log.info("BOSS项目范围交付:无信息点交付信息");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //类型信息交付
|
|
|
+ objectInfoCollectService.insert(content);
|
|
|
+ }
|
|
|
|
|
|
- Map<String,List<RelationDefineCollect>> resultMap = new HashMap<>();
|
|
|
- for (RelationDefineCollect relationCollect : relationCollects) {
|
|
|
- ArrayNode sourceTypeCodes = relationCollect.getSourceTypeCodes();
|
|
|
+ /**
|
|
|
+ * 初始化交付范围关系定义
|
|
|
+ * @param deliverPlanList
|
|
|
+ * @param relDefineCollectList
|
|
|
+ */
|
|
|
+ private void initDeliveryGraphRel(List<DeliveryPlanDTO> deliverPlanList,List<RelationDefineCollect> relDefineCollectList) throws Exception {
|
|
|
+ if(CollUtil.isEmpty(deliverPlanList) || CollUtil.isEmpty(relDefineCollectList)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Set<String> allTypeCodes = relDefineCollectList.stream().map(RelationDefineCollect::getId).collect(Collectors.toSet());
|
|
|
+ List<RelationDefineCollect> result = new ArrayList<>();
|
|
|
+ for (RelationDefineCollect relCollect : relDefineCollectList) {
|
|
|
+ ArrayNode sourceTypeCodes = relCollect.getSourceTypeCodes();
|
|
|
+ //获取源端和末端对象类型在交付范围内的对象类型
|
|
|
if(CollUtil.isNotEmpty(sourceTypeCodes)){
|
|
|
- sourceTypeCodes.forEach(item->{
|
|
|
- List<RelationDefineCollect> list = new ArrayList<>();
|
|
|
- });
|
|
|
+ sourceTypeCodes = getInDeliveryTypeCode(sourceTypeCodes, allTypeCodes);
|
|
|
}
|
|
|
- ArrayNode endTypeCodes = relationCollect.getEndTypeCodes();
|
|
|
+ ArrayNode endTypeCodes = relCollect.getEndTypeCodes();
|
|
|
+ if(CollUtil.isNotEmpty(endTypeCodes)){
|
|
|
+ endTypeCodes = getInDeliveryTypeCode(endTypeCodes, allTypeCodes);
|
|
|
+ }
|
|
|
+ if(CollUtil.isEmpty(sourceTypeCodes) && CollUtil.isEmpty(endTypeCodes)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //重置源端和末端对象类型
|
|
|
+ relCollect.setSourceTypeCodes(sourceTypeCodes);
|
|
|
+ relCollect.setEndTypeCodes(endTypeCodes);
|
|
|
+ //设置项目信息
|
|
|
+ relCollect.setProjectId(relDefineCollectList.get(0).getProjectId());
|
|
|
+ result.add(relCollect);
|
|
|
}
|
|
|
- */
|
|
|
- return new HashMap<>();
|
|
|
+ //2.初始化关系交付范围
|
|
|
+ relationDefineCollectService.insert(result);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取类型在交付范围内的关系数据
|
|
|
+ * @param typeCodes
|
|
|
+ * @param allTypeCodes
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private ArrayNode getInDeliveryTypeCode(ArrayNode typeCodes,Set<String> allTypeCodes){
|
|
|
+ ArrayNode array = JsonNodeFactory.instance.arrayNode();
|
|
|
+ if(CollUtil.isEmpty(typeCodes) || CollUtil.isEmpty(allTypeCodes)){
|
|
|
+ return array;
|
|
|
+ }
|
|
|
+ typeCodes.forEach(item->{
|
|
|
+ if(allTypeCodes.contains(item)){
|
|
|
+ array.add(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return array;
|
|
|
+ }
|
|
|
}
|