Commit d36e3961 by wangli

修改

1 parent b723a628
...@@ -3,18 +3,18 @@ package com.dituhui.pea.order.service; ...@@ -3,18 +3,18 @@ package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
public interface BusinessLayerService { import java.util.List;
Result<?> businessLayers();
public interface BusinessLayerService {
Result<?> businessLayerUniversal(); Result<?> businessLayerUniversal();
Result<?> businessCustomLayers(); Result<?> businessCustomLayers(String levelType, String levelValue, long page, long size);
Result<?> businessCustomLayer(); Result<?> businessCustomLayer(String layerId);
Result<?> businessCustomLayerAdd(); Result<?> businessCustomLayerAdd(String branchId, String layerName, String layerDesc, List<String> skillCodes);
Result<?> businessCustomLayerUpdate(); Result<?> businessCustomLayerUpdate(String layerId, String layerDesc, List<String> skillCodes);
Result<?> businessCustomLayerRemove(); Result<?> businessCustomLayerRemove(String layerId);
} }
package com.dituhui.pea.order.service.impl; package com.dituhui.pea.order.service.impl;
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.Result;
import com.dituhui.pea.common.ResultEnum; import com.dituhui.pea.common.ResultEnum;
import com.dituhui.pea.order.dao.MapLayerCustomizeMPDao;
import com.dituhui.pea.order.dao.MapLayerCustomizeSkillMPDao;
import com.dituhui.pea.order.entity.MapLayerCustomize;
import com.dituhui.pea.order.entity.MapLayerCustomizeSkill;
import com.dituhui.pea.order.feign.ISaaSRemoteService; import com.dituhui.pea.order.feign.ISaaSRemoteService;
import com.dituhui.pea.order.feign.dto.LayerDTO; import com.dituhui.pea.order.feign.dto.LayerDTO;
import com.dituhui.pea.order.service.BusinessLayerService; import com.dituhui.pea.order.service.BusinessLayerService;
...@@ -9,13 +15,28 @@ import com.dituhui.pea.order.utils.TypeUtils; ...@@ -9,13 +15,28 @@ import com.dituhui.pea.order.utils.TypeUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
public class BusinessLayerServiceImpl implements BusinessLayerService { public class BusinessLayerServiceImpl implements BusinessLayerService {
@Autowired
private MapLayerCustomizeMPDao mapLayerCustomizeMPDao;
@Autowired
private MapLayerCustomizeSkillMPDao mapLayerCustomizeSkillMPDao;
@Autowired @Autowired
private ISaaSRemoteService saasRemoteService; private ISaaSRemoteService saasRemoteService;
...@@ -24,29 +45,24 @@ public class BusinessLayerServiceImpl implements BusinessLayerService { ...@@ -24,29 +45,24 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
String ak; String ak;
@Override @Override
public Result<?> businessLayers() {
return null;
}
@Override
public Result<?> businessLayerUniversal() { public Result<?> businessLayerUniversal() {
return null; return null;
} }
@Override @Override
public Result<?> businessCustomLayers() { public Result<?> businessCustomLayers(String levelType, String leveValue, long page, long size) {
return null; return null;
} }
@Override @Override
public Result<?> businessCustomLayer() { public Result<?> businessCustomLayer(String layerId) {
return null; return null;
} }
@Transactional
@Override @Override
public Result<?> businessCustomLayerAdd() { public Result<?> businessCustomLayerAdd(String branchId, String layerName, String layerDesc, List<String> skillCodes) {
String layerName = "上海大区苏州分部基础技能";
// 同步创建saas图层,返回layerId // 同步创建saas图层,返回layerId
String result = saasRemoteService.addLayer(ak, layerName, 1, 1); String result = saasRemoteService.addLayer(ak, layerName, 1, 1);
log.info("addLayer params:{} result:{}", layerName, result); log.info("addLayer params:{} result:{}", layerName, result);
...@@ -59,15 +75,36 @@ public class BusinessLayerServiceImpl implements BusinessLayerService { ...@@ -59,15 +75,36 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
return Result.success(null); return Result.success(null);
} }
@Transactional
@Override @Override
public Result<?> businessCustomLayerUpdate() { public Result<?> businessCustomLayerUpdate(String layerId, String layerDesc, List<String> skillCodes) throws BusinessException{
return null; MapLayerCustomize layer = mapLayerCustomizeMPDao.getByLayerId(layerId);
if (layer == null) {
throw new BusinessException("图层不存在");
}
// 更新描述信息
layer.setLayerDescribe(layerDesc);
mapLayerCustomizeMPDao.updateById(layer);
// 更新技能
this.updateLayerSkills(layerId, new HashSet<>(skillCodes));
return Result.success(null);
} }
@Override @Override
public Result<?> businessCustomLayerRemove() { public Result<?> businessCustomLayerRemove(String layerId) throws BusinessException{
String layerId = ""; MapLayerCustomize layer = mapLayerCustomizeMPDao.getByLayerId(layerId);
if (layer == null) {
throw new BusinessException("图层不存在");
}
// 更新状态为删除状态
layer.setStatus(0);
mapLayerCustomizeMPDao.updateById(layer);
// 同步创建saas图层,返回layerId // 同步创建saas图层,返回layerId
String result = saasRemoteService.deleteLayer(ak, layerId); String result = saasRemoteService.deleteLayer(ak, layerId);
log.info("deleteLayer params:{} result:{}", layerId, result); log.info("deleteLayer params:{} result:{}", layerId, result);
...@@ -75,7 +112,44 @@ public class BusinessLayerServiceImpl implements BusinessLayerService { ...@@ -75,7 +112,44 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
if (!ResultEnum.SUCCESS.getCode().equals(saasResult.getCode())) { if (!ResultEnum.SUCCESS.getCode().equals(saasResult.getCode())) {
return Result.failure(saasResult.getMessage()); return Result.failure(saasResult.getMessage());
} }
return null; return Result.success(null);
}
private void updateLayerSkills(String layerId, Set<String> skillCodes){
// 更新技能信息
// 更新状态为0
LambdaUpdateWrapper<MapLayerCustomizeSkill> wrapper = new LambdaUpdateWrapper<>();
wrapper.set(MapLayerCustomizeSkill::getStatus, 0);
wrapper.eq(MapLayerCustomizeSkill::getLayerId, layerId);
mapLayerCustomizeSkillMPDao.update(null, wrapper);
List<MapLayerCustomizeSkill> skills = mapLayerCustomizeSkillMPDao.selectByLayerId(layerId);
Set<String> db = skills.stream().map(MapLayerCustomizeSkill::getSkillCode).collect(Collectors.toSet());
// 需要更新为有效的
Set<String> updates = new HashSet<>(db);
updates.retainAll(skillCodes);
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);
// 需要新增插入的
Set<String> adds = new HashSet<>(skillCodes);
adds.removeAll(db);
for(String skillCode: adds){
MapLayerCustomizeSkill c = new MapLayerCustomizeSkill();
c.setLayerId(layerId);
c.setSkillCode(skillCode);
c.setStatus(1);
c.setMemo("");
c.setCreateTime(LocalDateTime.now());
mapLayerCustomizeSkillMPDao.insert(c);
}
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!