Commit a44aca0c by wangli

mp2jpa

1 parent 15683bbc
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.MapBlockInfoEntity;
import com.dituhui.pea.order.entity.MapLayerCustomizeEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.dituhui.pea.order.service.impl;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.common.ResultEnum;
......@@ -14,7 +13,6 @@ import com.dituhui.pea.order.feign.ISaaSRemoteService;
import com.dituhui.pea.order.service.BusinessLayerService;
import com.dituhui.pea.order.utils.TypeUtils;
import com.google.gson.internal.LinkedTreeMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -40,7 +38,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
@Autowired
private MapLayerCustomizeDao mapLayerCustomizeDao;
@Autowired
private MapLayerCustomizeSkillMPDao mapLayerCustomizeSkillMPDao;
private MapLayerCustomizeSkillDao mapLayerCustomizeSkillDao;
@Autowired
private OrgGroupDao orgGroupDao;
@Autowired
......@@ -83,9 +81,9 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
//获取分页列表
Specification<MapLayerCustomizeEntity> specification = (root, query, criteriaBuilder) -> {
Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1);
Predicate branchIdPredicate = root.get("branchId").in(branchIds);
return criteriaBuilder.and(statusPredicate, branchIdPredicate);
Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1);
Predicate branchIdPredicate = root.get("branchId").in(branchIds);
return criteriaBuilder.and(statusPredicate, branchIdPredicate);
};
Sort sort = Sort.by(Sort.Order.asc("layerId"));
PageRequest pageRequest = PageRequest.of(page - 1, size, sort);
......@@ -134,9 +132,9 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
}
// 获取技能code列表
List<MapLayerCustomizeSkill> skills = mapLayerCustomizeSkillMPDao.selectByLayerId(layerId);
List<MapLayerCustomizeSkillEntity> skills = mapLayerCustomizeSkillDao.findByLayerId(layerId);
List<String> skillCodes = skills.stream().filter(s -> s.getStatus() == 1).map(
MapLayerCustomizeSkill::getSkillCode).collect(Collectors.toList());
MapLayerCustomizeSkillEntity::getSkillCode).collect(Collectors.toList());
// 获取branchName
String branchName = "";
......@@ -217,13 +215,13 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
if (layer == null) {
throw new BusinessException("图层不存在");
}
// 检查下面是否还有区块
List<MapBlockInfoEntity> blocks = mapBlockInfoDao.findByLayerId(layerId);
if (CollectionUtils.isNotEmpty(blocks)) {
return Result.failure("该图层下面还有区块");
}
// 同步删除saas图层
String result = saasRemoteService.deleteLayer(ak, layer.getSaasLayerId());
log.info("deleteLayer params:{} result:{}", layerId, result);
......@@ -243,37 +241,29 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
// 更新技能信息
// 更新状态为0
LambdaUpdateWrapper<MapLayerCustomizeSkill> wrapper = new LambdaUpdateWrapper<>();
wrapper.set(MapLayerCustomizeSkill::getStatus, 0);
wrapper.eq(MapLayerCustomizeSkill::getLayerId, layerId);
mapLayerCustomizeSkillMPDao.update(null, wrapper);
mapLayerCustomizeSkillDao.updateStatusByLayerId(0, layerId);
List<MapLayerCustomizeSkill> skills = mapLayerCustomizeSkillMPDao.selectByLayerId(layerId);
Set<String> db = skills.stream().map(MapLayerCustomizeSkill::getSkillCode).collect(Collectors.toSet());
List<MapLayerCustomizeSkillEntity> skills = mapLayerCustomizeSkillDao.findByLayerId(layerId);
Set<String> db = skills.stream().map(MapLayerCustomizeSkillEntity::getSkillCode).collect(Collectors.toSet());
// 需要更新为有效的
Set<String> updates = new HashSet<>(db);
updates.retainAll(skillCodes);
if(!updates.isEmpty()) {
LambdaUpdateWrapper<MapLayerCustomizeSkill> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(MapLayerCustomizeSkill::getStatus, 1);
updateWrapper.eq(MapLayerCustomizeSkill::getLayerId, layerId);
updateWrapper.in(MapLayerCustomizeSkill::getSkillCode, new ArrayList<>(updates));
mapLayerCustomizeSkillMPDao.update(null, updateWrapper);
if (!updates.isEmpty()) {
mapLayerCustomizeSkillDao.updateStatusByLayerIdAndSkillCodeIn(1, layerId, new ArrayList<>(updates));
}
// 需要新增插入的
Set<String> adds = new HashSet<>(skillCodes);
adds.removeAll(db);
for (String skillCode : adds) {
MapLayerCustomizeSkill c = new MapLayerCustomizeSkill();
MapLayerCustomizeSkillEntity c = new MapLayerCustomizeSkillEntity();
c.setLayerId(layerId);
c.setSkillCode(skillCode);
c.setStatus(1);
c.setMemo("");
c.setCreateTime(LocalDateTime.now());
mapLayerCustomizeSkillMPDao.insert(c);
entityManager.persist(c);
}
}
......@@ -284,8 +274,8 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
Map<String, String> skillMap = skills.stream().collect(Collectors.toMap(
SkillInfoEntity::getSkillCode, SkillInfoEntity::getSkill));
List<MapLayerCustomizeSkill> laySkills = mapLayerCustomizeSkillMPDao.selectByLayerId(layerId);
for (MapLayerCustomizeSkill s : laySkills) {
List<MapLayerCustomizeSkillEntity> laySkills = mapLayerCustomizeSkillDao.findByLayerId(layerId);
for (MapLayerCustomizeSkillEntity s : laySkills) {
if (s.getStatus() == 0) {
continue;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!