Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@ -1,22 +1,31 @@
|
||||
package com.xjrsoft.module.sales.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.google.api.client.util.Lists;
|
||||
import com.pictc.datalog.DataOperationContent;
|
||||
import com.pictc.datalog.DataOperationListener;
|
||||
import com.pictc.enums.BusinessCode;
|
||||
import com.pictc.enums.ExceptionCommonCode;
|
||||
import com.pictc.jdbc.JdbcTools;
|
||||
import com.pictc.jdbc.model.JdbcParam;
|
||||
import com.pictc.utils.StringUtils;
|
||||
import com.xjrsoft.common.exception.BusinessException;
|
||||
import com.xjrsoft.common.model.result.R;
|
||||
import com.xjrsoft.common.page.ConventPage;
|
||||
import com.xjrsoft.common.page.PageOutput;
|
||||
import com.xjrsoft.common.utils.VoToColumnUtil;
|
||||
import com.xjrsoft.module.datalog.service.DatalogService;
|
||||
import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
|
||||
import com.xjrsoft.module.sales.dto.LngCustomerGroupPageDto;
|
||||
import com.xjrsoft.module.sales.dto.UpdateLngCustomerGroupDto;
|
||||
import com.xjrsoft.module.sales.entity.LngCustomerGroup;
|
||||
import com.xjrsoft.module.sales.service.ICustomerGroupService;
|
||||
import com.xjrsoft.module.sales.vo.LngCustomerGroupPageVo;
|
||||
import com.xjrsoft.module.sales.vo.LngCustomerGroupVo;
|
||||
import com.xjrsoft.module.system.client.ICodeRuleClient;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -40,21 +49,21 @@ public class CustomerGroupController {
|
||||
|
||||
private final ICustomerGroupService customerGroupService;
|
||||
private final DatalogService dataService;
|
||||
private final ICodeRuleClient codeRuleClient;
|
||||
private final String GRP_CODE = "grpCode";
|
||||
|
||||
@GetMapping(value = "/page")
|
||||
// @GetMapping(value = "/page")
|
||||
@ApiOperation(value="LngCustomerGroup列表(分页)")
|
||||
@SaCheckPermission("customerGroup:list")
|
||||
public R page(@Valid LngCustomerGroupPageDto dto){
|
||||
|
||||
LambdaQueryWrapper<LngCustomerGroup> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper
|
||||
.like(StrUtil.isNotBlank(dto.getGrpCode()),LngCustomerGroup::getGrpCode,dto.getGrpCode())
|
||||
.like(StrUtil.isNotBlank(dto.getTypeCode()),LngCustomerGroup::getTypeCode,dto.getTypeCode())
|
||||
.eq(StrUtil.isNotBlank(dto.getTypeCode()),LngCustomerGroup::getTypeCode,dto.getTypeCode())
|
||||
.between(ObjectUtil.isNotNull(dto.getDateFromStart()) && ObjectUtil.isNotNull(dto.getDateFromEnd()),LngCustomerGroup::getDateFrom,dto.getDateFromStart(),dto.getDateFromEnd())
|
||||
.between(ObjectUtil.isNotNull(dto.getDateToStart()) && ObjectUtil.isNotNull(dto.getDateToEnd()),LngCustomerGroup::getDateTo,dto.getDateToStart(),dto.getDateToEnd())
|
||||
.like(StrUtil.isNotBlank(dto.getGrpName()),LngCustomerGroup::getGrpName,dto.getGrpName())
|
||||
.like(StrUtil.isNotBlank(dto.getNote()),LngCustomerGroup::getNote,dto.getNote())
|
||||
.orderByDesc(LngCustomerGroup::getId)
|
||||
.orderByAsc(LngCustomerGroup::getGrpCode)
|
||||
.select(LngCustomerGroup.class,x -> VoToColumnUtil.fieldsToColumns(LngCustomerGroupPageVo.class).contains(x.getProperty()));
|
||||
IPage<LngCustomerGroup> page = customerGroupService.page(ConventPage.getPage(dto), queryWrapper);
|
||||
PageOutput<LngCustomerGroupPageVo> pageOutput = ConventPage.getPageOutput(page, LngCustomerGroupPageVo.class);
|
||||
@ -65,35 +74,96 @@ public class CustomerGroupController {
|
||||
@ApiOperation(value="根据id查询LngCustomerGroup信息")
|
||||
@SaCheckPermission("customerGroup:detail")
|
||||
public R info(@RequestParam Long id){
|
||||
LngCustomerGroup lngCustomerGroup = customerGroupService.getByIdDeep(id);
|
||||
if (lngCustomerGroup == null) {
|
||||
return R.error("找不到此数据!");
|
||||
}
|
||||
return R.ok(BeanUtil.toBean(lngCustomerGroup, LngCustomerGroupVo.class));
|
||||
return R.ok(customerGroupService.info(id));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/datalog")
|
||||
@ApiOperation(value="根据id查询LngCustomerGroup数据详细日志")
|
||||
@SaCheckPermission("customerGroup:datalog")
|
||||
public R datalog(@RequestParam Long id){
|
||||
List<DataChangeLogVo> logs = dataService.findLogsByEntityId(UpdateLngCustomerGroupDto.class,id);
|
||||
return R.ok(logs);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "新增LngCustomerGroup")
|
||||
@SaCheckPermission("customerGroup:add")
|
||||
public R add(@Valid @RequestBody UpdateLngCustomerGroupDto dto){
|
||||
UpdateLngCustomerGroupDto res = dataService.insert(dto);
|
||||
String code = codeRuleClient.genEncode(GRP_CODE);
|
||||
dto.setGrpCode("GD" + code);
|
||||
UpdateLngCustomerGroupDto res = dataService.insert(dto, new DataOperationListener<UpdateLngCustomerGroupDto>() {
|
||||
@Override
|
||||
public UpdateLngCustomerGroupDto before(DataOperationContent<UpdateLngCustomerGroupDto> content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateLngCustomerGroupDto after(DataOperationContent<UpdateLngCustomerGroupDto> content) {
|
||||
execAfter(content.getTableName(), content.getIdValue(), "I");
|
||||
return content.getObj();
|
||||
}
|
||||
});
|
||||
codeRuleClient.useEncode(GRP_CODE);
|
||||
return R.ok(res.getId());
|
||||
}
|
||||
|
||||
private void execAfter(String table, Long id, String sign) {
|
||||
String sql = StringUtils.format("{? = call pc_{0}.f_save(?, ?)}", table);
|
||||
List<JdbcParam> params = Lists.newArrayList();
|
||||
JdbcParam outParam = JdbcParam.ofString(null).setOut(true);
|
||||
params.add(outParam);
|
||||
params.add(JdbcParam.ofLong(id));
|
||||
params.add(JdbcParam.ofString(sign));
|
||||
JdbcTools.call(sql,params);
|
||||
String error = outParam.getStringValue();
|
||||
if (StringUtils.isNotEmpty(error)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_SAVE_EXEC_ERROR, error));
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation(value = "修改LngCustomerGroup")
|
||||
@SaCheckPermission("customerGroup:edit")
|
||||
public R update(@Valid @RequestBody UpdateLngCustomerGroupDto dto){
|
||||
return R.ok(dataService.updateById(dto));
|
||||
return R.ok(dataService.updateById(dto, new DataOperationListener<UpdateLngCustomerGroupDto>() {
|
||||
@Override
|
||||
public UpdateLngCustomerGroupDto before(DataOperationContent<UpdateLngCustomerGroupDto> content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateLngCustomerGroupDto after(DataOperationContent<UpdateLngCustomerGroupDto> content) {
|
||||
execAfter(content.getTableName(), content.getIdValue(), "U");
|
||||
return content.getObj();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation(value = "删除")
|
||||
@SaCheckPermission("customerGroup:delete")
|
||||
public R delete(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(dataService.deleteByIds(UpdateLngCustomerGroupDto.class, ids));
|
||||
return R.ok(dataService.deleteByIds(UpdateLngCustomerGroupDto.class, ids, new DataOperationListener<UpdateLngCustomerGroupDto>() {
|
||||
@Override
|
||||
public UpdateLngCustomerGroupDto before(DataOperationContent<UpdateLngCustomerGroupDto> content) {
|
||||
String sql = StringUtils.format("{? = call pc_{0}.f_before_delete(?)}", content.getTableName());
|
||||
List<JdbcParam> params = Lists.newArrayList();
|
||||
JdbcParam outParam = JdbcParam.ofString(null).setOut(true);
|
||||
params.add(outParam);
|
||||
params.add(JdbcParam.ofLong(content.getIdValue()));
|
||||
JdbcTools.call(sql,params);
|
||||
String error = outParam.getStringValue();
|
||||
if (StringUtils.isNotEmpty(error)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_DELETE_EXEC_ERROR, error));
|
||||
}
|
||||
return content.getObj();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateLngCustomerGroupDto after(DataOperationContent<UpdateLngCustomerGroupDto> content) {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,6 +5,8 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.pictc.datalog.DataOperationContent;
|
||||
import com.pictc.datalog.DataOperationListener;
|
||||
import com.xjrsoft.common.model.result.R;
|
||||
import com.xjrsoft.common.page.ConventPage;
|
||||
import com.xjrsoft.common.page.PageOutput;
|
||||
@ -111,7 +113,17 @@ public class GradeSystemController {
|
||||
@ApiOperation(value = "启用LngGradeSystem")
|
||||
@SaCheckPermission("gradeSystem:enable")
|
||||
public R enable(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(dataService.enable(UpdateLngGradeSystemDto.class,ids));
|
||||
return R.ok(dataService.enable(UpdateLngGradeSystemDto.class,ids, new DataOperationListener<UpdateLngGradeSystemDto>() {
|
||||
@Override
|
||||
public UpdateLngGradeSystemDto before(DataOperationContent<UpdateLngGradeSystemDto> content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateLngGradeSystemDto after(DataOperationContent<UpdateLngGradeSystemDto> content) {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@ -119,7 +131,17 @@ public class GradeSystemController {
|
||||
@ApiOperation(value = "禁用LngGradeSystem")
|
||||
@SaCheckPermission("gradeSystem:disable")
|
||||
public R disable(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(dataService.disable(UpdateLngGradeSystemDto.class,ids));
|
||||
return R.ok(dataService.disable(UpdateLngGradeSystemDto.class, ids, new DataOperationListener<UpdateLngGradeSystemDto>() {
|
||||
@Override
|
||||
public UpdateLngGradeSystemDto before(DataOperationContent<UpdateLngGradeSystemDto> content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateLngGradeSystemDto after(DataOperationContent<UpdateLngGradeSystemDto> content) {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ public class LngCustomerGroupCustomer implements Serializable {
|
||||
*/
|
||||
@ApiModelProperty("主键")
|
||||
@TableId
|
||||
private String id;
|
||||
private Long id;
|
||||
/**
|
||||
* 组编码
|
||||
*/
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.xjrsoft.module.sales.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.xjrsoft.module.sales.entity.LngCustomerGroupCustomer;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@ -11,6 +12,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface LngCustomerGroupCustomerMapper extends MPJBaseMapper<LngCustomerGroupCustomer> {
|
||||
public interface LngCustomerGroupCustomerMapper extends MPJBaseMapper<LngCustomerGroupCustomer>, BaseMapper<LngCustomerGroupCustomer> {
|
||||
|
||||
}
|
||||
|
||||
@ -3,7 +3,12 @@ package com.xjrsoft.module.sales.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.xjrsoft.module.sales.entity.LngCustomerGroup;
|
||||
import com.xjrsoft.module.sales.vo.LngCustomerGroupCustomerVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @title: mapper
|
||||
@ -12,6 +17,17 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface LngCustomerGroupMapper extends MPJBaseMapper<LngCustomerGroup> {
|
||||
public interface LngCustomerGroupMapper extends MPJBaseMapper<LngCustomerGroup>, BaseMapper<LngCustomerGroup> {
|
||||
|
||||
@Select("SELECT t1.*, t2.cu_name, dd1.name AS di_name, dd2.name AS type_name, dd3.name AS class_name" +
|
||||
" FROM lng_customer_group_customer t1" +
|
||||
" LEFT JOIN lng_customer t2 on t1.cu_code = t2.cu_code" +
|
||||
" LEFT JOIN xjr_dictionary_item di1 ON di1.code = 'LNG_NATURE'" +
|
||||
" LEFT JOIN xjr_dictionary_detail dd1 ON dd1.item_id = di1.id AND dd1.code = t2.d_i" +
|
||||
" LEFT JOIN xjr_dictionary_item di2 ON di2.code = 'LNG_CU_TYP'" +
|
||||
" LEFT JOIN xjr_dictionary_detail dd2 ON dd2.item_id = di2.id AND dd2.code = t2.type_code" +
|
||||
" LEFT JOIN xjr_dictionary_item di3 ON di3.code = 'LNG_CLASS'" +
|
||||
" LEFT JOIN xjr_dictionary_detail dd3 ON dd3.item_id = di3.id AND dd3.code = t2.class_code" +
|
||||
" WHERE t1.grp_code = #{grpCode}")
|
||||
List<LngCustomerGroupCustomerVo> queryCustomerList(@Param("grpCode") String grpCode);
|
||||
}
|
||||
|
||||
@ -4,8 +4,7 @@ import com.github.yulichang.base.MPJBaseService;
|
||||
import com.github.yulichang.extension.mapping.base.MPJDeepService;
|
||||
import com.github.yulichang.extension.mapping.base.MPJRelationService;
|
||||
import com.xjrsoft.module.sales.entity.LngCustomerGroup;
|
||||
|
||||
import java.util.List;
|
||||
import com.xjrsoft.module.sales.vo.LngCustomerGroupVo;
|
||||
|
||||
/**
|
||||
* @title: service
|
||||
@ -15,27 +14,12 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
public interface ICustomerGroupService extends MPJBaseService<LngCustomerGroup>, MPJDeepService<LngCustomerGroup>, MPJRelationService<LngCustomerGroup> {
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param lngCustomerGroup
|
||||
* @return
|
||||
*/
|
||||
Boolean add(LngCustomerGroup lngCustomerGroup);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param lngCustomerGroup
|
||||
* @return
|
||||
*/
|
||||
Boolean update(LngCustomerGroup lngCustomerGroup);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
Boolean delete(List<Long> ids);
|
||||
* 详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
LngCustomerGroupVo info(Long id);
|
||||
}
|
||||
|
||||
@ -5,8 +5,6 @@ import com.github.yulichang.extension.mapping.base.MPJDeepService;
|
||||
import com.github.yulichang.extension.mapping.base.MPJRelationService;
|
||||
import com.xjrsoft.module.sales.entity.LngGradeSystem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @title: service
|
||||
* @Author 管理员
|
||||
@ -15,27 +13,5 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
public interface IGradeSystemService extends MPJBaseService<LngGradeSystem>, MPJDeepService<LngGradeSystem>, MPJRelationService<LngGradeSystem> {
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param lngGradeSystem
|
||||
* @return
|
||||
*/
|
||||
Boolean add(LngGradeSystem lngGradeSystem);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param lngGradeSystem
|
||||
* @return
|
||||
*/
|
||||
Boolean update(LngGradeSystem lngGradeSystem);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
Boolean delete(List<Long> ids);
|
||||
}
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
package com.xjrsoft.module.sales.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import com.pictc.enums.BusinessCode;
|
||||
import com.xjrsoft.common.exception.BusinessException;
|
||||
import com.xjrsoft.module.sales.entity.LngCustomerGroup;
|
||||
import com.xjrsoft.module.sales.entity.LngCustomerGroupCustomer;
|
||||
import com.xjrsoft.module.sales.mapper.LngCustomerGroupCustomerMapper;
|
||||
import com.xjrsoft.module.sales.mapper.LngCustomerGroupMapper;
|
||||
import com.xjrsoft.module.sales.service.ICustomerGroupService;
|
||||
import com.xjrsoft.module.sales.vo.LngCustomerGroupCustomerVo;
|
||||
import com.xjrsoft.module.sales.vo.LngCustomerGroupVo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @title: service
|
||||
@ -24,65 +24,19 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class CustomerGroupServiceImpl extends MPJBaseServiceImpl<LngCustomerGroupMapper, LngCustomerGroup> implements ICustomerGroupService {
|
||||
private final LngCustomerGroupMapper customerGroupLngCustomerGroupMapper;
|
||||
|
||||
private final LngCustomerGroupCustomerMapper customerGroupLngCustomerGroupCustomerMapper;
|
||||
|
||||
private final LngCustomerGroupMapper lngCustomerGroupMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean add(LngCustomerGroup lngCustomerGroup) {
|
||||
customerGroupLngCustomerGroupMapper.insert(lngCustomerGroup);
|
||||
for (LngCustomerGroupCustomer lngCustomerGroupCustomer : lngCustomerGroup.getLngCustomerGroupCustomerList()) {
|
||||
lngCustomerGroupCustomer.setGrpCode(lngCustomerGroup.getGrpCode());
|
||||
customerGroupLngCustomerGroupCustomerMapper.insert(lngCustomerGroupCustomer);
|
||||
public LngCustomerGroupVo info(Long id) {
|
||||
LngCustomerGroup lngCustomerGroup = lngCustomerGroupMapper.selectById(id);
|
||||
if (Objects.isNull(lngCustomerGroup)) {
|
||||
throw new BusinessException(BusinessCode.of(10500, "找不到此数据!"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean update(LngCustomerGroup lngCustomerGroup) {
|
||||
customerGroupLngCustomerGroupMapper.updateById(lngCustomerGroup);
|
||||
//********************************* LngCustomerGroupCustomer 增删改 开始 *******************************************/
|
||||
{
|
||||
// 查出所有子级的id
|
||||
List<LngCustomerGroupCustomer> lngCustomerGroupCustomerList = customerGroupLngCustomerGroupCustomerMapper.selectList(Wrappers.lambdaQuery(LngCustomerGroupCustomer.class).eq(LngCustomerGroupCustomer::getGrpCode, lngCustomerGroup.getGrpCode()).select(LngCustomerGroupCustomer::getId));
|
||||
List<String> lngCustomerGroupCustomerIds = lngCustomerGroupCustomerList.stream().map(LngCustomerGroupCustomer::getId).collect(Collectors.toList());
|
||||
//原有子表单 没有被删除的主键
|
||||
List<String> lngCustomerGroupCustomerOldIds = lngCustomerGroup.getLngCustomerGroupCustomerList().stream().map(LngCustomerGroupCustomer::getId).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
//找到需要删除的id
|
||||
List<String> lngCustomerGroupCustomerRemoveIds = lngCustomerGroupCustomerIds.stream().filter(item -> !lngCustomerGroupCustomerOldIds.contains(item)).collect(Collectors.toList());
|
||||
|
||||
for (LngCustomerGroupCustomer lngCustomerGroupCustomer : lngCustomerGroup.getLngCustomerGroupCustomerList()) {
|
||||
//如果不等于空则修改
|
||||
if (lngCustomerGroupCustomer.getId() != null) {
|
||||
customerGroupLngCustomerGroupCustomerMapper.updateById(lngCustomerGroupCustomer);
|
||||
}
|
||||
//如果等于空 则新增
|
||||
else {
|
||||
//已经不存在的id 删除
|
||||
lngCustomerGroupCustomer.setGrpCode(lngCustomerGroup.getGrpCode());
|
||||
customerGroupLngCustomerGroupCustomerMapper.insert(lngCustomerGroupCustomer);
|
||||
}
|
||||
}
|
||||
//已经不存在的id 删除
|
||||
if(lngCustomerGroupCustomerRemoveIds.size() > 0){
|
||||
customerGroupLngCustomerGroupCustomerMapper.deleteBatchIds(lngCustomerGroupCustomerRemoveIds);
|
||||
}
|
||||
}
|
||||
//********************************* LngCustomerGroupCustomer 增删改 结束 *******************************************/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean delete(List<Long> ids) {
|
||||
customerGroupLngCustomerGroupMapper.deleteBatchIds(ids);
|
||||
customerGroupLngCustomerGroupCustomerMapper.delete(Wrappers.lambdaQuery(LngCustomerGroupCustomer.class).in(LngCustomerGroupCustomer::getGrpCode, ids));
|
||||
|
||||
return true;
|
||||
LngCustomerGroupVo lngCustomerGroupVo = new LngCustomerGroupVo();
|
||||
BeanUtils.copyProperties(lngCustomerGroup, lngCustomerGroupVo);
|
||||
List<LngCustomerGroupCustomerVo> list = lngCustomerGroupMapper.queryCustomerList(lngCustomerGroupVo.getGrpCode());
|
||||
lngCustomerGroupVo.setLngCustomerGroupCustomerList(list);
|
||||
return lngCustomerGroupVo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,11 @@
|
||||
package com.xjrsoft.module.sales.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import com.xjrsoft.module.sales.entity.LngGradeSystem;
|
||||
import com.xjrsoft.module.sales.entity.LngGradeSystemItem;
|
||||
import com.xjrsoft.module.sales.mapper.LngGradeSystemItemMapper;
|
||||
import com.xjrsoft.module.sales.mapper.LngGradeSystemMapper;
|
||||
import com.xjrsoft.module.sales.service.IGradeSystemService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @title: service
|
||||
@ -24,65 +16,5 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class GradeSystemServiceImpl extends MPJBaseServiceImpl<LngGradeSystemMapper, LngGradeSystem> implements IGradeSystemService {
|
||||
private final LngGradeSystemMapper gradeSystemLngGradeSystemMapper;
|
||||
|
||||
private final LngGradeSystemItemMapper gradeSystemLngGradeSystemItemMapper;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean add(LngGradeSystem lngGradeSystem) {
|
||||
gradeSystemLngGradeSystemMapper.insert(lngGradeSystem);
|
||||
for (LngGradeSystemItem lngGradeSystemItem : lngGradeSystem.getLngGradeSystemItemList()) {
|
||||
lngGradeSystemItem.setGsId(lngGradeSystem.getId());
|
||||
gradeSystemLngGradeSystemItemMapper.insert(lngGradeSystemItem);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean update(LngGradeSystem lngGradeSystem) {
|
||||
gradeSystemLngGradeSystemMapper.updateById(lngGradeSystem);
|
||||
//********************************* LngGradeSystemItem 增删改 开始 *******************************************/
|
||||
{
|
||||
// 查出所有子级的id
|
||||
List<LngGradeSystemItem> lngGradeSystemItemList = gradeSystemLngGradeSystemItemMapper.selectList(Wrappers.lambdaQuery(LngGradeSystemItem.class).eq(LngGradeSystemItem::getGsId, lngGradeSystem.getId()).select(LngGradeSystemItem::getId));
|
||||
List<Long> lngGradeSystemItemIds = lngGradeSystemItemList.stream().map(LngGradeSystemItem::getId).collect(Collectors.toList());
|
||||
//原有子表单 没有被删除的主键
|
||||
List<Long> lngGradeSystemItemOldIds = lngGradeSystem.getLngGradeSystemItemList().stream().map(LngGradeSystemItem::getId).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
//找到需要删除的id
|
||||
List<Long> lngGradeSystemItemRemoveIds = lngGradeSystemItemIds.stream().filter(item -> !lngGradeSystemItemOldIds.contains(item)).collect(Collectors.toList());
|
||||
|
||||
for (LngGradeSystemItem lngGradeSystemItem : lngGradeSystem.getLngGradeSystemItemList()) {
|
||||
//如果不等于空则修改
|
||||
if (lngGradeSystemItem.getId() != null) {
|
||||
gradeSystemLngGradeSystemItemMapper.updateById(lngGradeSystemItem);
|
||||
}
|
||||
//如果等于空 则新增
|
||||
else {
|
||||
//已经不存在的id 删除
|
||||
lngGradeSystemItem.setGsId(lngGradeSystem.getId());
|
||||
gradeSystemLngGradeSystemItemMapper.insert(lngGradeSystemItem);
|
||||
}
|
||||
}
|
||||
//已经不存在的id 删除
|
||||
if(lngGradeSystemItemRemoveIds.size() > 0){
|
||||
gradeSystemLngGradeSystemItemMapper.deleteBatchIds(lngGradeSystemItemRemoveIds);
|
||||
}
|
||||
}
|
||||
//********************************* LngGradeSystemItem 增删改 结束 *******************************************/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean delete(List<Long> ids) {
|
||||
gradeSystemLngGradeSystemMapper.deleteBatchIds(ids);
|
||||
gradeSystemLngGradeSystemItemMapper.delete(Wrappers.lambdaQuery(LngGradeSystemItem.class).in(LngGradeSystemItem::getGsId, ids));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user