|
@@ -19,8 +19,10 @@ import com.persagy.dmp.basic.model.CodeTableTypeEnum;
|
|
|
import com.persagy.dmp.codetable.client.CodeTableDataFacade;
|
|
|
import com.persagy.dmp.codetable.entity.CodeTableData;
|
|
|
import com.persagy.dmp.common.constant.CommonConstant;
|
|
|
+import com.persagy.dmp.common.constant.ResponseCode;
|
|
|
import com.persagy.dmp.common.constant.ValidEnum;
|
|
|
import com.persagy.dmp.common.context.AppContext;
|
|
|
+import com.persagy.dmp.common.exception.BusinessException;
|
|
|
import com.persagy.dmp.common.helper.SpringHelper;
|
|
|
import com.persagy.dmp.common.model.entity.BaseEntity;
|
|
|
import com.persagy.dmp.common.model.response.CommonResult;
|
|
@@ -341,6 +343,65 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
|
|
|
List<List<ObjectDigital>> objList = objectDigitalMapper.queryObjectListByGraphCodeAndRelCode(requestData);
|
|
|
return analysisQueryResultList(objList,requestData,false,false);
|
|
|
}
|
|
|
+ /***
|
|
|
+ * Description: 根据对象id批量更新对象的classCode
|
|
|
+ * @param objectDigitals : 对象数组
|
|
|
+ * @return : com.persagy.dmp.common.model.response.CommonResult<java.util.List<com.persagy.dmp.digital.entity.ObjectDigital>>
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/9/27 17:46
|
|
|
+ * Update By lijie 2021/9/27 17:46
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public CommonResult<List<ObjectDigital>> batchUpdateClassCodesByIds(List<ObjectDigital> objectDigitals) {
|
|
|
+ // 1.校验数据必填
|
|
|
+ for (ObjectDigital objectDigital : objectDigitals) {
|
|
|
+ if (StrUtil.isBlank(objectDigital.getId())
|
|
|
+ || StrUtil.isBlank(objectDigital.getClassCode())){
|
|
|
+ throw new BusinessException(ResponseCode.A0400.getCode(),
|
|
|
+ StrUtil.format("id:{}或classCode:{}不能为空",objectDigital.getId(),
|
|
|
+ objectDigital.getClassCode()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 2.校验对象是否都存在以及对象要更新的classCode是否符合
|
|
|
+ // 2.1 获得对象id集合
|
|
|
+ Set<String> objIds = objectDigitals.stream()
|
|
|
+ .map(BaseEntity::getId)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ Map<String, ObjectDigital> digitalMap = objectDigitals
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(ObjectDigital::getId, obj -> obj, (k1, k2) -> k1));
|
|
|
+ // 2.2 根据对象id查询对象信息及对象的分类对应的classCode集合
|
|
|
+ List<ObjectDigital> queryObjs = objectDigitalMapper.queryObjectListByIds(objIds);
|
|
|
+ if (CollUtil.isEmpty(queryObjs)){
|
|
|
+ throw new BusinessException(ResponseCode.A0400.getCode(),
|
|
|
+ StrUtil.format("id不存在:{}",objIds));
|
|
|
+ }
|
|
|
+ // 2.3 校验对象是否都存在
|
|
|
+ Map<String, ObjectDigital> queryObjMap = queryObjs
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(BaseEntity::getId, obj -> obj, (k1, k2) -> k1));
|
|
|
+ List<ObjectDigital> updateObjs = new ArrayList<>();
|
|
|
+ for (String objId : objIds) {
|
|
|
+ if (!queryObjMap.containsKey(objId)){
|
|
|
+ throw new BusinessException(ResponseCode.A0400.getCode(),
|
|
|
+ StrUtil.format("id不存在:{}",objId));
|
|
|
+ }
|
|
|
+ ObjectDigital queryObj = queryObjMap.get(objId);
|
|
|
+ Set<String> validClassCodes = CollUtil.defaultIfEmpty(queryObj.getObjTypeClassCodes(), new HashSet<>());
|
|
|
+ ObjectDigital objectDigital = digitalMap.get(objId);
|
|
|
+ if (!validClassCodes.contains(objectDigital.getClassCode())){
|
|
|
+ throw new BusinessException(ResponseCode.A0400.getCode(),
|
|
|
+ StrUtil.format("id:{}的classCode不符合:{}",objectDigital.getId(),objectDigital.getClassCode()));
|
|
|
+ }
|
|
|
+ queryObj.setClassCode(objectDigital.getClassCode());
|
|
|
+ queryObj.setUpdateApp(AppContext.getContext().getAppId());
|
|
|
+ queryObj.setModifier(AppContext.getContext().getAccountId());
|
|
|
+ updateObjs.add(queryObj);
|
|
|
+ }
|
|
|
+ // 3.校验通过,直接更新
|
|
|
+ updateBatchById(updateObjs);
|
|
|
+ return ResultHelper.multi(new ArrayList<>());
|
|
|
+ }
|
|
|
|
|
|
/***
|
|
|
* Description: 通用处理分页数据方法
|