update
This commit is contained in:
@ -35,10 +35,19 @@ public interface TableNameConstants {
|
||||
|
||||
|
||||
/**
|
||||
* 费用名称
|
||||
* 税率表
|
||||
*/
|
||||
String LNG_B_TAX = "lng_b_tax";
|
||||
|
||||
/**
|
||||
* 管道气路线表
|
||||
*/
|
||||
String LNG_B_PNG_LINE = "lng_b_png_line";
|
||||
|
||||
/**
|
||||
* 管道气上下载点表
|
||||
*/
|
||||
String LNG_B_STATION_PNG = "lng_b_station_png";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,36 +1,40 @@
|
||||
package com.xjrsoft.module.mdm.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.xjrsoft.common.constant.GlobalConstant;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.xjrsoft.common.model.result.R;
|
||||
import com.xjrsoft.common.page.ConventPage;
|
||||
import com.xjrsoft.common.page.PageOutput;
|
||||
import com.xjrsoft.common.model.result.R;
|
||||
import com.xjrsoft.common.utils.VoToColumnUtil;
|
||||
import com.xjrsoft.module.mdm.dto.AddLngBStationPngDto;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBStationPngDto;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
|
||||
import com.xjrsoft.module.datalog.service.DatalogService;
|
||||
import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
|
||||
import com.xjrsoft.module.mdm.dto.LngBStationPngPageDto;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBBankDto;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBStationPngDto;
|
||||
import com.xjrsoft.module.mdm.entity.LngBStationPng;
|
||||
import com.xjrsoft.module.mdm.service.IPipeGasDownloadPointService;
|
||||
import com.xjrsoft.module.mdm.vo.LngBStationPngPageVo;
|
||||
|
||||
import com.xjrsoft.module.datalog.service.DatalogService;
|
||||
import com.xjrsoft.module.mdm.vo.LngBStationPngVo;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @title: 管道气上下载点
|
||||
@ -39,7 +43,7 @@ import java.util.List;
|
||||
* @Version 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/mdm" + "/pipeGasDownloadPoint")
|
||||
@RequestMapping("/mdm/pipeGasDownloadPoint")
|
||||
@Api(value = "/mdm" + "/pipeGasDownloadPoint",tags = "管道气上下载点代码")
|
||||
@AllArgsConstructor
|
||||
public class PipeGasDownloadPointController {
|
||||
@ -94,23 +98,45 @@ public class PipeGasDownloadPointController {
|
||||
@ApiOperation(value = "新增LngBStationPng")
|
||||
@SaCheckPermission("pipeGasDownloadPoint:add")
|
||||
public R add(@Valid @RequestBody UpdateLngBStationPngDto dto){
|
||||
UpdateLngBStationPngDto res = dataService.insert(dto);
|
||||
return R.ok(res.getId());
|
||||
return R.ok(pipeGasDownloadPointService.add(dto));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation(value = "修改LngBStationPng")
|
||||
@SaCheckPermission("pipeGasDownloadPoint:edit")
|
||||
public R update(@Valid @RequestBody UpdateLngBStationPngDto dto){
|
||||
return R.ok(dataService.updateById(dto));
|
||||
return R.ok(pipeGasDownloadPointService.update(dto));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation(value = "删除")
|
||||
@SaCheckPermission("pipeGasDownloadPoint:delete")
|
||||
public R delete(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(dataService.deleteByIds(UpdateLngBStationPngDto.class, ids));
|
||||
return R.ok(dataService.deleteByIds(UpdateLngBStationPngDto.class, ids));
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/enable")
|
||||
@ApiOperation(value = "启用")
|
||||
@SaCheckPermission("pipeGasDownloadPoint:enable")
|
||||
public R enable(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(pipeGasDownloadPointService.enable(ids));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/disable")
|
||||
@ApiOperation(value = "禁用")
|
||||
@SaCheckPermission("pipeGasDownloadPoint:disable")
|
||||
public R disable(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(pipeGasDownloadPointService.disable(ids));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/datalog")
|
||||
@ApiOperation(value="根据id查询LngBStationPng数据详细日志")
|
||||
@SaCheckPermission("pipeGasDownloadPoint:datalog")
|
||||
public R datalog(@RequestParam Long id){
|
||||
List<DataChangeLogVo> logs = dataService.findLogsByEntityId(UpdateLngBBankDto.class,id);
|
||||
return R.ok(logs);
|
||||
}
|
||||
|
||||
}
|
||||
@ -17,11 +17,13 @@ import com.xjrsoft.module.mdm.dto.UpdateLngBPngLineDto;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
|
||||
import com.xjrsoft.module.mdm.dto.LngBPngLinePageDto;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBBankDto;
|
||||
import com.xjrsoft.module.mdm.entity.LngBPngLine;
|
||||
import com.xjrsoft.module.mdm.service.IPipelineGgasLineService;
|
||||
import com.xjrsoft.module.mdm.vo.LngBPngLinePageVo;
|
||||
|
||||
import com.xjrsoft.module.datalog.service.DatalogService;
|
||||
import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
|
||||
import com.xjrsoft.module.mdm.vo.LngBPngLineVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -39,7 +41,7 @@ import java.util.List;
|
||||
* @Version 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/mdm" + "/pipelineGgasLine")
|
||||
@RequestMapping("/mdm/pipelineGgasLine")
|
||||
@Api(value = "/mdm" + "/pipelineGgasLine",tags = "管道气管线代码")
|
||||
@AllArgsConstructor
|
||||
public class PipelineGgasLineController {
|
||||
@ -85,23 +87,45 @@ public class PipelineGgasLineController {
|
||||
@ApiOperation(value = "新增LngBPngLine")
|
||||
@SaCheckPermission("pipelineGgasLine:add")
|
||||
public R add(@Valid @RequestBody UpdateLngBPngLineDto dto){
|
||||
UpdateLngBPngLineDto res = dataService.insert(dto);
|
||||
return R.ok(res.getId());
|
||||
return R.ok(pipelineGgasLineService.add(dto));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation(value = "修改LngBPngLine")
|
||||
@SaCheckPermission("pipelineGgasLine:edit")
|
||||
public R update(@Valid @RequestBody UpdateLngBPngLineDto dto){
|
||||
return R.ok(dataService.updateById(dto));
|
||||
return R.ok(pipelineGgasLineService.update(dto));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation(value = "删除")
|
||||
@SaCheckPermission("pipelineGgasLine:delete")
|
||||
public R delete(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(dataService.deleteByIds(UpdateLngBPngLineDto.class, ids));
|
||||
return R.ok(dataService.deleteByIds(UpdateLngBPngLineDto.class, ids));
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/enable")
|
||||
@ApiOperation(value = "启用")
|
||||
@SaCheckPermission("pipelineGgasLine:enable")
|
||||
public R enable(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(pipelineGgasLineService.enable(ids));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/disable")
|
||||
@ApiOperation(value = "禁用")
|
||||
@SaCheckPermission("pipelineGgasLine:disable")
|
||||
public R disable(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(pipelineGgasLineService.disable(ids));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/datalog")
|
||||
@ApiOperation(value="根据id查询LngBPngLine数据详细日志")
|
||||
@SaCheckPermission("pipelineGgasLine:datalog")
|
||||
public R datalog(@RequestParam Long id){
|
||||
List<DataChangeLogVo> logs = dataService.findLogsByEntityId(UpdateLngBBankDto.class,id);
|
||||
return R.ok(logs);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,13 +1,11 @@
|
||||
package com.xjrsoft.module.mdm.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
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.mdm.entity.LngBStationPng;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBStationPngDto;
|
||||
import com.xjrsoft.module.mdm.entity.LngBStationPng;
|
||||
|
||||
/**
|
||||
* @title: service
|
||||
* @Author 管理员
|
||||
@ -16,4 +14,12 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
public interface IPipeGasDownloadPointService extends IService<LngBStationPng> {
|
||||
|
||||
Boolean enable(List<Long> ids);
|
||||
|
||||
Boolean disable(List<Long> ids);
|
||||
|
||||
Long add(UpdateLngBStationPngDto dto);
|
||||
|
||||
Long update(UpdateLngBStationPngDto dto);
|
||||
}
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package com.xjrsoft.module.mdm.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
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.mdm.entity.LngBPngLine;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBPngLineDto;
|
||||
import com.xjrsoft.module.mdm.entity.LngBPngLine;
|
||||
|
||||
/**
|
||||
* @title: service
|
||||
* @Author 管理员
|
||||
@ -16,4 +14,12 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
public interface IPipelineGgasLineService extends IService<LngBPngLine> {
|
||||
|
||||
Boolean disable(List<Long> ids);
|
||||
|
||||
Boolean enable(List<Long> ids);
|
||||
|
||||
Long add(UpdateLngBPngLineDto dto);
|
||||
|
||||
Long update(UpdateLngBPngLineDto dto);
|
||||
}
|
||||
|
||||
@ -38,16 +38,16 @@ public class BankServiceImpl extends ServiceImpl<LngBBankMapper, LngBBank> imple
|
||||
|
||||
private final ICodeRuleClient codeRuleClient;
|
||||
|
||||
private final String BANKCODE = "bankCode";
|
||||
private final String BANK_CODE = "bankCode";
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long add(UpdateLngBBankDto dto) {
|
||||
String code = codeRuleClient.genEncode(BANKCODE);
|
||||
String code = codeRuleClient.genEncode(BANK_CODE);
|
||||
dto.setCode(code);
|
||||
this.checkParams(dto);
|
||||
UpdateLngBBankDto res = DataLogTools.insert(dto);
|
||||
codeRuleClient.useEncode(BANKCODE);
|
||||
codeRuleClient.useEncode(BANK_CODE);
|
||||
this.addOrUpdateAfter(res.getId());
|
||||
return res.getId();
|
||||
}
|
||||
@ -65,7 +65,7 @@ public class BankServiceImpl extends ServiceImpl<LngBBankMapper, LngBBank> imple
|
||||
public boolean enable(List<Long> ids) {
|
||||
DataLogTools.enable(UpdateLngBBankDto.class,ids);
|
||||
for (Long id : ids) {
|
||||
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_PRICE_TERM, id);
|
||||
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_BANK, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
@ -79,7 +79,7 @@ public class BankServiceImpl extends ServiceImpl<LngBBankMapper, LngBBank> imple
|
||||
DataLogTools.disable(UpdateLngBBankDto.class,ids);
|
||||
|
||||
for (Long id : ids) {
|
||||
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_PRICE_TERM, id);
|
||||
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_BANK, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public class CountryRegionServiceImpl extends ServiceImpl<LngBRegionMapper, LngB
|
||||
public boolean enable(List<Long> ids) {
|
||||
dataService.enable(UpdateLngBRegionDto.class,ids);
|
||||
for (Long id : ids) {
|
||||
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_PRICE_TERM, id);
|
||||
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_REGION, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
@ -74,7 +74,7 @@ public class CountryRegionServiceImpl extends ServiceImpl<LngBRegionMapper, LngB
|
||||
public boolean disable(List<Long> ids) {
|
||||
dataService.disable(UpdateLngBRegionDto.class,ids);
|
||||
for (Long id : ids) {
|
||||
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_PRICE_TERM, id);
|
||||
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_REGION, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
|
||||
@ -1,17 +1,27 @@
|
||||
package com.xjrsoft.module.mdm.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import com.pictc.constant.FieldNameConstants;
|
||||
import com.pictc.constant.TableNameConstants;
|
||||
import com.pictc.enums.BusinessCode;
|
||||
import com.pictc.enums.ExceptionCommonCode;
|
||||
import com.pictc.utils.DataLogTools;
|
||||
import com.xjrsoft.common.exception.BusinessException;
|
||||
import com.xjrsoft.module.common.db.service.CommonCallService;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBStationPngDto;
|
||||
import com.xjrsoft.module.mdm.entity.LngBStationPng;
|
||||
import com.xjrsoft.module.mdm.mapper.LngBStationPngMapper;
|
||||
import com.xjrsoft.module.mdm.service.IPipeGasDownloadPointService;
|
||||
import com.xjrsoft.module.system.client.ICodeRuleClient;
|
||||
|
||||
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;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
|
||||
/**
|
||||
* @title: service
|
||||
@ -22,4 +32,82 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class PipeGasDownloadPointServiceImpl extends ServiceImpl<LngBStationPngMapper, LngBStationPng> implements IPipeGasDownloadPointService {
|
||||
|
||||
private final CommonCallService commonCallService;
|
||||
|
||||
private final ICodeRuleClient codeRuleClient;
|
||||
|
||||
private final String PNG_DL_POINT_CODE = "pngDlPointCode";
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long add(UpdateLngBStationPngDto dto) {
|
||||
String code = codeRuleClient.genEncode(PNG_DL_POINT_CODE);
|
||||
dto.setCode(code);
|
||||
this.checkParams(dto);
|
||||
UpdateLngBStationPngDto res = DataLogTools.insert(dto);
|
||||
codeRuleClient.useEncode(PNG_DL_POINT_CODE);
|
||||
this.addOrUpdateAfter(res.getId());
|
||||
return res.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long update(UpdateLngBStationPngDto dto) {
|
||||
this.checkParams(dto);
|
||||
UpdateLngBStationPngDto res = DataLogTools.update(dto);
|
||||
this.addOrUpdateAfter(res.getId());
|
||||
return res.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean enable(List<Long> ids) {
|
||||
DataLogTools.enable(UpdateLngBStationPngDto.class,ids);
|
||||
for (Long id : ids) {
|
||||
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_STATION_PNG, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean disable(List<Long> ids) {
|
||||
DataLogTools.disable(UpdateLngBStationPngDto.class,ids);
|
||||
|
||||
for (Long id : ids) {
|
||||
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_STATION_PNG, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void checkParams(UpdateLngBStationPngDto dto) {
|
||||
Long codeCount = this.baseMapper.selectCount(new LambdaQueryWrapper<LngBStationPng>()
|
||||
.eq(LngBStationPng::getCode, dto.getCode()).ne(dto.getId() != null, LngBStationPng::getId, dto.getId()));
|
||||
if (codeCount > 0) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION,
|
||||
FieldNameConstants.CODE));
|
||||
}
|
||||
|
||||
Long nameCount = this.baseMapper.selectCount(new LambdaQueryWrapper<LngBStationPng>()
|
||||
.eq(LngBStationPng::getFullName, dto.getFullName()).ne(dto.getId() != null, LngBStationPng::getId, dto.getId()));
|
||||
if (nameCount > 0) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION,
|
||||
FieldNameConstants.FULL_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
private void addOrUpdateAfter(Long id) {
|
||||
String msg = commonCallService.saveAfter(TableNameConstants.LNG_B_STATION_PNG, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,15 +2,31 @@ package com.xjrsoft.module.mdm.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import com.pictc.constant.FieldNameConstants;
|
||||
import com.pictc.constant.TableNameConstants;
|
||||
import com.pictc.enums.BusinessCode;
|
||||
import com.pictc.enums.ExceptionCommonCode;
|
||||
import com.pictc.utils.DataLogTools;
|
||||
import com.xjrsoft.common.exception.BusinessException;
|
||||
import com.xjrsoft.module.common.db.service.CommonCallService;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBPngLineDto;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBPngLineDto;
|
||||
import com.xjrsoft.module.mdm.entity.LngBPngLine;
|
||||
import com.xjrsoft.module.mdm.entity.LngBPngLine;
|
||||
import com.xjrsoft.module.mdm.mapper.LngBPngLineMapper;
|
||||
import com.xjrsoft.module.mdm.service.IPipelineGgasLineService;
|
||||
import com.xjrsoft.module.system.client.ICodeRuleClient;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
|
||||
/**
|
||||
@ -22,4 +38,83 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class PipelineGgasLineServiceImpl extends ServiceImpl<LngBPngLineMapper, LngBPngLine> implements IPipelineGgasLineService {
|
||||
|
||||
|
||||
private final CommonCallService commonCallService;
|
||||
|
||||
private final ICodeRuleClient codeRuleClient;
|
||||
|
||||
private final String PNG_LINE_CODE = "pngLineCode";
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long add(UpdateLngBPngLineDto dto) {
|
||||
String code = codeRuleClient.genEncode(PNG_LINE_CODE);
|
||||
dto.setCode(code);
|
||||
this.checkParams(dto);
|
||||
UpdateLngBPngLineDto res = DataLogTools.insert(dto);
|
||||
codeRuleClient.useEncode(PNG_LINE_CODE);
|
||||
this.addOrUpdateAfter(res.getId());
|
||||
return res.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long update(UpdateLngBPngLineDto dto) {
|
||||
this.checkParams(dto);
|
||||
UpdateLngBPngLineDto res = DataLogTools.update(dto);
|
||||
this.addOrUpdateAfter(res.getId());
|
||||
return res.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean enable(List<Long> ids) {
|
||||
DataLogTools.enable(UpdateLngBPngLineDto.class,ids);
|
||||
for (Long id : ids) {
|
||||
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_PNG_LINE, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean disable(List<Long> ids) {
|
||||
DataLogTools.disable(UpdateLngBPngLineDto.class,ids);
|
||||
|
||||
for (Long id : ids) {
|
||||
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_PNG_LINE, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void checkParams(UpdateLngBPngLineDto dto) {
|
||||
Long codeCount = this.baseMapper.selectCount(new LambdaQueryWrapper<LngBPngLine>()
|
||||
.eq(LngBPngLine::getCode, dto.getCode()).ne(dto.getId() != null, LngBPngLine::getId, dto.getId()));
|
||||
if (codeCount > 0) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION,
|
||||
FieldNameConstants.CODE));
|
||||
}
|
||||
|
||||
Long nameCount = this.baseMapper.selectCount(new LambdaQueryWrapper<LngBPngLine>()
|
||||
.eq(LngBPngLine::getFullName, dto.getFullName()).ne(dto.getId() != null, LngBPngLine::getId, dto.getId()));
|
||||
if (nameCount > 0) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION,
|
||||
FieldNameConstants.FULL_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
private void addOrUpdateAfter(Long id) {
|
||||
String msg = commonCallService.saveAfter(TableNameConstants.LNG_B_PNG_LINE, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user