|
@@ -8,15 +8,23 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
import com.persagy.dmp.common.constant.ValidEnum;
|
|
import com.persagy.dmp.common.constant.ValidEnum;
|
|
import com.persagy.dmp.common.model.entity.BaseEntity;
|
|
import com.persagy.dmp.common.model.entity.BaseEntity;
|
|
-import com.persagy.dmp.define.entity.ObjectInfoDefine;
|
|
|
|
import com.persagy.dmp.define.entity.ObjectTypeDefine;
|
|
import com.persagy.dmp.define.entity.ObjectTypeDefine;
|
|
import com.persagy.dmp.delivery.dto.ObjectTypeCollectDTO;
|
|
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.ObjectTypeCollect;
|
|
|
|
+import com.persagy.dmp.delivery.entity.RelationDefineCollect;
|
|
import com.persagy.dmp.rwd.define.service.IObjectTypeService;
|
|
import com.persagy.dmp.rwd.define.service.IObjectTypeService;
|
|
import com.persagy.dmp.rwd.delivery.dao.ObjectTypeCollectMapper;
|
|
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.IObjectTypeCollectService;
|
|
|
|
+import com.persagy.dmp.rwd.delivery.service.IRelationDefineCollectService;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -31,7 +39,8 @@ import java.util.stream.Collectors;
|
|
* @date:2021/10/13
|
|
* @date:2021/10/13
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
-public class ObjectTypeCollectServiceImpl extends ServiceImpl<com.persagy.dmp.rwd.delivery.dao.ObjectTypeCollectMapper, ObjectTypeCollect> implements IObjectTypeCollectService {
|
|
|
|
|
|
+@Slf4j
|
|
|
|
+public class ObjectTypeCollectServiceImpl extends ServiceImpl<ObjectTypeCollectMapper, ObjectTypeCollect> implements IObjectTypeCollectService {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private com.persagy.dmp.rwd.delivery.dao.ObjectTypeCollectMapper ObjectTypeCollectMapper;
|
|
private com.persagy.dmp.rwd.delivery.dao.ObjectTypeCollectMapper ObjectTypeCollectMapper;
|
|
@@ -39,6 +48,18 @@ public class ObjectTypeCollectServiceImpl extends ServiceImpl<com.persagy.dmp.rw
|
|
@Autowired
|
|
@Autowired
|
|
private IObjectTypeService objectTypeService;
|
|
private IObjectTypeService objectTypeService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IBossBdtpTypeRelService bossBdtpTypeRelService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IObjectTypeCollectService objectTypeCollectService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IObjectInfoCollectService objectInfoCollectService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IRelationDefineCollectService relationDefineCollectService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 数量统计
|
|
* 数量统计
|
|
* @param queryWrapper 查询条件
|
|
* @param queryWrapper 查询条件
|
|
@@ -60,53 +81,108 @@ public class ObjectTypeCollectServiceImpl extends ServiceImpl<com.persagy.dmp.rw
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 分页查询对象类型交付范围
|
|
|
|
- * @param page 分页条件
|
|
|
|
- * @param queryWrapper 查询条件
|
|
|
|
|
|
+ * 设置项目交付范围信息
|
|
|
|
+ * @param voList
|
|
* @return
|
|
* @return
|
|
|
|
+ * @throws Exception
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Page queryByCondition(Page page, Wrapper<ObjectTypeCollect> queryWrapper) {
|
|
|
|
- //查询交付范围内的对象类型信息
|
|
|
|
- Page selectPage = ObjectTypeCollectMapper.selectPage(page, queryWrapper);
|
|
|
|
- List<ObjectTypeCollect> records = (List<ObjectTypeCollect>)selectPage.getRecords();
|
|
|
|
- if(CollUtil.isEmpty(records)){
|
|
|
|
- return selectPage;
|
|
|
|
|
|
+ public List<DeliveryOrderDTO> settingProjectDelivery(List<DeliveryOrderDTO> voList) throws Exception {
|
|
|
|
+ //1. 查询商品映射关系
|
|
|
|
+ Map<String, Set<String>> typeRelMap = queryBossBdtpTypeRel();
|
|
|
|
+ if(CollUtil.isEmpty(typeRelMap)){
|
|
|
|
+ return voList;
|
|
}
|
|
}
|
|
- Map<String, ObjectTypeDefine> typeDefineMap = queryDefineObjectType(records);
|
|
|
|
|
|
+ //2. 查询BDTP标准交付范围-对象类型
|
|
|
|
+ Map<String, ObjectTypeCollect> typeCollectMap = queryBdtpObjectTypeCollect();
|
|
|
|
+ //3. 查询BDTP标准交付范围-信息点
|
|
|
|
+ Map<String, List<ObjectInfoCollect>> infoCollectMap = queryBdtpObjectInfoCollect();
|
|
|
|
+ //4. 查询BDTP标准交付范围- 关系
|
|
|
|
+ Map<String, List<RelationDefineCollect>> relationCollectMap = queryBdtpObjectRelCollect();
|
|
|
|
|
|
- List<ObjectTypeCollectDTO> result = new ArrayList<>();
|
|
|
|
- records.forEach(item->{
|
|
|
|
- ObjectTypeCollectDTO collectType = new ObjectTypeCollectDTO();
|
|
|
|
- //设置标准类型定义信息
|
|
|
|
- String defineTypeId = item.getDefineTypeId();
|
|
|
|
- if(StringUtils.isNotEmpty(defineTypeId)){
|
|
|
|
- ObjectTypeDefine objectTypeDefine = typeDefineMap.get(defineTypeId);
|
|
|
|
- if(objectTypeDefine != null){
|
|
|
|
- BeanUtils.copyProperties(objectTypeDefine,collectType);
|
|
|
|
|
|
+ //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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 初始化对象类型交付范围
|
|
|
|
+ * @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;
|
|
}
|
|
}
|
|
- BeanUtils.copyProperties(item,collectType);
|
|
|
|
- result.add(collectType);
|
|
|
|
- });
|
|
|
|
- selectPage.setRecords(result);
|
|
|
|
- return selectPage;
|
|
|
|
|
|
+ typeCollect.setProjectId(deliveryOrderDTO.getProjectId());
|
|
|
|
+ typeCollect.setIsDelivery(1);
|
|
|
|
+ content.add(typeCollect);
|
|
|
|
+ }
|
|
|
|
+ if(CollUtil.isEmpty(content)){
|
|
|
|
+ log.info("BOSS项目范围交付:无类型交付信息");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ //类型信息交付
|
|
|
|
+ objectTypeCollectService.insert(content);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * 查询标准类型定义
|
|
|
|
- * @return
|
|
|
|
|
|
+ * 初始化对象类型交付范围
|
|
|
|
+ * @param deliveryOrderDTO
|
|
|
|
+ * @param allTypeCodes
|
|
*/
|
|
*/
|
|
- private Map<String, ObjectTypeDefine> queryDefineObjectType(List<ObjectTypeCollect> records){
|
|
|
|
- Set<String> ids = records.stream().map(ObjectTypeCollect::getDefineTypeId).collect(Collectors.toSet());
|
|
|
|
- QueryWrapper<ObjectTypeDefine> queryWrapper = new QueryWrapper<>();
|
|
|
|
- queryWrapper.in("id",ids);
|
|
|
|
- //queryWrapper.select("id","name");
|
|
|
|
- List<ObjectTypeDefine> objectTypeDefines = objectTypeService.queryByCondition(queryWrapper);
|
|
|
|
- if(CollUtil.isEmpty(objectTypeDefines)){
|
|
|
|
- return new HashMap<>();
|
|
|
|
|
|
+ private void initDelivertyObjectInfo(DeliveryOrderDTO deliveryOrderDTO,Set<String> allTypeCodes,Map<String, List<ObjectInfoCollect>> infoCollectMap) throws Exception{
|
|
|
|
+ if(CollUtil.isEmpty(allTypeCodes) || CollUtil.isEmpty(infoCollectMap)){
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- return objectTypeDefines.stream().collect(Collectors.toMap(ObjectTypeDefine::getId, item->item, (k1, k2) -> k1));
|
|
|
|
|
|
+ //组装信息点交付信息
|
|
|
|
+ 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);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -162,6 +238,7 @@ public class ObjectTypeCollectServiceImpl extends ServiceImpl<com.persagy.dmp.rw
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 填充已交付的对象类ID
|
|
* 填充已交付的对象类ID
|
|
* @param voList
|
|
* @param voList
|
|
@@ -191,4 +268,127 @@ public class ObjectTypeCollectServiceImpl extends ServiceImpl<com.persagy.dmp.rw
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页查询对象类型交付范围
|
|
|
|
+ * @param page 分页条件
|
|
|
|
+ * @param queryWrapper 查询条件
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Page queryByCondition(Page page, Wrapper<ObjectTypeCollect> queryWrapper) {
|
|
|
|
+ //查询交付范围内的对象类型信息
|
|
|
|
+ Page selectPage = ObjectTypeCollectMapper.selectPage(page, queryWrapper);
|
|
|
|
+ List<ObjectTypeCollect> records = (List<ObjectTypeCollect>)selectPage.getRecords();
|
|
|
|
+ if(CollUtil.isEmpty(records)){
|
|
|
|
+ return selectPage;
|
|
|
|
+ }
|
|
|
|
+ Map<String, ObjectTypeDefine> typeDefineMap = queryDefineObjectType(records);
|
|
|
|
+
|
|
|
|
+ List<ObjectTypeCollectDTO> result = new ArrayList<>();
|
|
|
|
+ records.forEach(item->{
|
|
|
|
+ ObjectTypeCollectDTO collectType = new ObjectTypeCollectDTO();
|
|
|
|
+ //设置标准类型定义信息
|
|
|
|
+ String defineTypeId = item.getDefineTypeId();
|
|
|
|
+ if(StringUtils.isNotEmpty(defineTypeId)){
|
|
|
|
+ ObjectTypeDefine objectTypeDefine = typeDefineMap.get(defineTypeId);
|
|
|
|
+ if(objectTypeDefine != null){
|
|
|
|
+ BeanUtils.copyProperties(objectTypeDefine,collectType);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ BeanUtils.copyProperties(item,collectType);
|
|
|
|
+ result.add(collectType);
|
|
|
|
+ });
|
|
|
|
+ selectPage.setRecords(result);
|
|
|
|
+ return selectPage;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询标准类型定义
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private Map<String, ObjectTypeDefine> queryDefineObjectType(List<ObjectTypeCollect> records){
|
|
|
|
+ Set<String> ids = records.stream().map(ObjectTypeCollect::getDefineTypeId).collect(Collectors.toSet());
|
|
|
|
+ QueryWrapper<ObjectTypeDefine> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.in("id",ids);
|
|
|
|
+ //queryWrapper.select("id","name");
|
|
|
|
+ List<ObjectTypeDefine> objectTypeDefines = objectTypeService.queryByCondition(queryWrapper);
|
|
|
|
+ if(CollUtil.isEmpty(objectTypeDefines)){
|
|
|
|
+ return new HashMap<>();
|
|
|
|
+ }
|
|
|
|
+ return objectTypeDefines.stream().collect(Collectors.toMap(ObjectTypeDefine::getId, item->item, (k1, k2) -> k1));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询商品类型映射关系
|
|
|
|
+ * @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(){
|
|
|
|
+ LambdaQueryWrapper<ObjectTypeCollect> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(ObjectTypeCollect::getGroupCode,"0");
|
|
|
|
+ wrapper.eq(ObjectTypeCollect::getProjectId,"0");
|
|
|
|
+ wrapper.eq(ObjectTypeCollect::getIsDelivery,1);
|
|
|
|
+ wrapper.eq(ObjectTypeCollect::getValid,ValidEnum.TRUE.getType());
|
|
|
|
+ List<ObjectTypeCollect> objectTypeCollects = objectTypeCollectService.queryByCondition(wrapper);
|
|
|
|
+ if(CollUtil.isEmpty(objectTypeCollects)){
|
|
|
|
+ return new HashMap<>();
|
|
|
|
+ }
|
|
|
|
+ return objectTypeCollects.stream().collect(Collectors.toMap(ObjectTypeCollect::getCode, item->item, (k1, k2) -> k1));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询BDTP标准交付范围-信息点
|
|
|
|
+ */
|
|
|
|
+ private Map<String, List<ObjectInfoCollect>> queryBdtpObjectInfoCollect(){
|
|
|
|
+ LambdaQueryWrapper<ObjectInfoCollect> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(ObjectInfoCollect::getGroupCode,"0");
|
|
|
|
+ wrapper.eq(ObjectInfoCollect::getProjectId,"0");
|
|
|
|
+ wrapper.eq(ObjectInfoCollect::getIsDelivery,1);
|
|
|
|
+ wrapper.eq(ObjectInfoCollect::getValid,ValidEnum.TRUE.getType());
|
|
|
|
+ List<ObjectInfoCollect> objectInfoCollects = objectInfoCollectService.queryByCondition(wrapper);
|
|
|
|
+ if(CollUtil.isEmpty(objectInfoCollects)){
|
|
|
|
+ return new HashMap<>();
|
|
|
|
+ }
|
|
|
|
+ return objectInfoCollects.stream().collect(Collectors.groupingBy(ObjectInfoCollect::getClassCode));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询BDTP标准交付范围-关系
|
|
|
|
+ */
|
|
|
|
+ private Map<String,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<>();
|
|
|
|
+ }/*
|
|
|
|
+
|
|
|
|
+ Map<String,List<RelationDefineCollect>> resultMap = new HashMap<>();
|
|
|
|
+ for (RelationDefineCollect relationCollect : relationCollects) {
|
|
|
|
+ ArrayNode sourceTypeCodes = relationCollect.getSourceTypeCodes();
|
|
|
|
+ if(CollUtil.isNotEmpty(sourceTypeCodes)){
|
|
|
|
+ sourceTypeCodes.forEach(item->{
|
|
|
|
+ List<RelationDefineCollect> list = new ArrayList<>();
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ ArrayNode endTypeCodes = relationCollect.getEndTypeCodes();
|
|
|
|
+ }
|
|
|
|
+ */
|
|
|
|
+ return new HashMap<>();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|