Commit b3dacffe by 丁伟峰

Merge remote-tracking branch 'origin/develop' into develop

2 parents b5ec0fe7 0cfe55cb
package com.dituhui.pea.order.controller; package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.BusinessCustomLayerAddReqDTO;
import com.dituhui.pea.order.dto.BusinessCustomLayerUpdateReqDTO;
import com.dituhui.pea.order.service.BusinessLayerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@Controller @Controller
@RequestMapping("/pea-order") @RequestMapping("/pea-order")
public class BusinessLayerController { public class BusinessLayerController {
@Autowired
private BusinessLayerService businessLayerService;
/** /**
* 获取通用图层 * 获取通用图层
...@@ -19,7 +27,13 @@ public class BusinessLayerController { ...@@ -19,7 +27,13 @@ public class BusinessLayerController {
@GetMapping("/business/layer/universal") @GetMapping("/business/layer/universal")
public Result<?> businessLayerUniversal() { public Result<?> businessLayerUniversal() {
// 通用图层 // 通用图层
return null; Result res = null;
try {
res = businessLayerService.businessLayerUniversal();
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
} }
/** /**
...@@ -34,7 +48,13 @@ public class BusinessLayerController { ...@@ -34,7 +48,13 @@ public class BusinessLayerController {
@GetMapping("/business/layer/custom/list") @GetMapping("/business/layer/custom/list")
public Result<?> businessCustomLayers(String levelType, String levelValue, long page, long size) { public Result<?> businessCustomLayers(String levelType, String levelValue, long page, long size) {
// 自定义图层列表 // 自定义图层列表
return null; Result res = null;
try {
res = businessLayerService.businessCustomLayers(levelType, levelValue, page, size);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
} }
/** /**
...@@ -45,31 +65,55 @@ public class BusinessLayerController { ...@@ -45,31 +65,55 @@ public class BusinessLayerController {
*/ */
@GetMapping("/business/layer/custom/detail") @GetMapping("/business/layer/custom/detail")
public Result<?> businessCustomLayer(String layerId) { public Result<?> businessCustomLayer(String layerId) {
// 自定义图层详情 Result res = null;
return null; try {
res = businessLayerService.businessCustomLayer(layerId);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
} }
/** /**
* 新增自定义图层 * 新增自定义图层
* *
* @param reqDTO::branchId 分部ID
* @param reqDTO::layerName 图层名称
* @param reqDTO::layerDesc 图层描述
* @param reqDTO::skills 技能code列表
* @return * @return
*/ */
@PostMapping("/business/layer/custom/add") @PostMapping("/business/layer/custom/add")
public Result<?> businessCustomLayerAdd() { public Result<?> businessCustomLayerAdd(@RequestBody BusinessCustomLayerAddReqDTO reqDTO) {
// 自定义图层新增 // 自定义图层新增
return null; Result res = null;
try {
res = businessLayerService.businessCustomLayerAdd(
reqDTO.getBranchId(), reqDTO.getLayerName(), reqDTO.getLayerDesc(), reqDTO.getSkills());
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
} }
/** /**
* 修改自定义图层 * 修改自定义图层
* *
* @param layerId 图层ID * @param reqDTO::layerId 图层ID
* @param reqDTO::layerDesc 图层描述
* @param reqDTO::skills 技能code列表
* @return * @return
*/ */
@PostMapping("/business/layer/custom/update") @PostMapping("/business/layer/custom/update")
public Result<?> businessCustomLayerUpdate(String layerId) { public Result<?> businessCustomLayerUpdate(@RequestBody BusinessCustomLayerUpdateReqDTO reqDTO) {
// 自定义图层修改 // 自定义图层修改
return null; Result res = null;
try {
res = businessLayerService.businessCustomLayerUpdate(reqDTO.getLayerId(), reqDTO.getLayerDesc(), reqDTO.getSkills());
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
} }
/** /**
...@@ -78,9 +122,15 @@ public class BusinessLayerController { ...@@ -78,9 +122,15 @@ public class BusinessLayerController {
* @param layerId 图层ID * @param layerId 图层ID
* @return * @return
*/ */
@PostMapping("/business/layer/custom/remove") @GetMapping("/business/layer/custom/remove")
public Result<?> businessCustomLayerRemove(String layerId) { public Result<?> businessCustomLayerRemove(String layerId) {
// 自定义图层删除 // 自定义图层删除
return null; Result res = null;
try {
res = businessLayerService.businessCustomLayerRemove(layerId);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
} }
} }
...@@ -3,7 +3,13 @@ package com.dituhui.pea.order.dao; ...@@ -3,7 +3,13 @@ package com.dituhui.pea.order.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dituhui.pea.order.entity.MapLayerCustomizeSkill; import com.dituhui.pea.order.entity.MapLayerCustomizeSkill;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper @Mapper
public interface MapLayerCustomizeSkillMPDao extends BaseMapper<MapLayerCustomizeSkill> { public interface MapLayerCustomizeSkillMPDao extends BaseMapper<MapLayerCustomizeSkill> {
@Select("select * from map_layer_customize_skill where layer_id=#{layerId};")
List<MapLayerCustomizeSkill> selectByLayerId(String layerId);
} }
package com.dituhui.pea.order.dto;
import lombok.Data;
import java.util.List;
@Data
public class BusinessCustomLayerAddReqDTO {
private String branchId;
private String layerName;
private String layerDesc;
private List<String> skills;
}
package com.dituhui.pea.order.dto;
import lombok.Data;
import java.util.List;
@Data
public class BusinessCustomLayerUpdateReqDTO {
private String layerId;
private String layerDesc;
private List<String> skills;
}
...@@ -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,44 +15,54 @@ import com.dituhui.pea.order.utils.TypeUtils; ...@@ -9,44 +15,54 @@ 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 @Autowired
private MapLayerCustomizeMPDao mapLayerCustomizeMPDao;
@Autowired
private MapLayerCustomizeSkillMPDao mapLayerCustomizeSkillMPDao;
@Autowired
private ISaaSRemoteService saasRemoteService; private ISaaSRemoteService saasRemoteService;
@Value("${SaaS.ak}") @Value("${SaaS.ak}")
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{
MapLayerCustomize layer = mapLayerCustomizeMPDao.getByLayerId(layerId);
if (layer == null) {
throw new BusinessException("图层不存在");
}
// 更新状态为删除状态
layer.setStatus(0);
mapLayerCustomizeMPDao.updateById(layer);
String layerId = "";
// 同步创建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);
...@@ -76,6 +113,43 @@ public class BusinessLayerServiceImpl implements BusinessLayerService { ...@@ -76,6 +113,43 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
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!