From 141da5498751336ff31592bf2f46b15196524c5e Mon Sep 17 00:00:00 2001 From: "t-shunyi.kuang" <846002312@qq.com> Date: Fri, 24 Oct 2025 15:49:36 +0800 Subject: [PATCH] update --- .../pictc/constant/TableNameConstants.java | 11 +- .../PipeGasDownloadPointController.java | 72 +++++++++---- .../PipelineGgasLineController.java | 34 +++++- .../service/IPipeGasDownloadPointService.java | 18 ++-- .../mdm/service/IPipelineGgasLineService.java | 18 ++-- .../mdm/service/impl/BankServiceImpl.java | 10 +- .../impl/CountryRegionServiceImpl.java | 4 +- .../impl/PipeGasDownloadPointServiceImpl.java | 102 ++++++++++++++++-- .../impl/PipelineGgasLineServiceImpl.java | 95 ++++++++++++++++ 9 files changed, 309 insertions(+), 55 deletions(-) diff --git a/itc-pcitc-dependencies/itc-pcitc-dependencies-api/src/main/java/com/pictc/constant/TableNameConstants.java b/itc-pcitc-dependencies/itc-pcitc-dependencies-api/src/main/java/com/pictc/constant/TableNameConstants.java index a942deb..8abd565 100644 --- a/itc-pcitc-dependencies/itc-pcitc-dependencies-api/src/main/java/com/pictc/constant/TableNameConstants.java +++ b/itc-pcitc-dependencies/itc-pcitc-dependencies-api/src/main/java/com/pictc/constant/TableNameConstants.java @@ -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"; } diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/PipeGasDownloadPointController.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/PipeGasDownloadPointController.java index 4c9845c..bcddd0a 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/PipeGasDownloadPointController.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/PipeGasDownloadPointController.java @@ -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 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 ids){ + return R.ok(pipeGasDownloadPointService.enable(ids)); + } + + + @PostMapping("/disable") + @ApiOperation(value = "禁用") + @SaCheckPermission("pipeGasDownloadPoint:disable") + public R disable(@Valid @RequestBody List ids){ + return R.ok(pipeGasDownloadPointService.disable(ids)); + } + + @GetMapping(value = "/datalog") + @ApiOperation(value="根据id查询LngBStationPng数据详细日志") + @SaCheckPermission("pipeGasDownloadPoint:datalog") + public R datalog(@RequestParam Long id){ + List logs = dataService.findLogsByEntityId(UpdateLngBBankDto.class,id); + return R.ok(logs); + } } \ No newline at end of file diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/PipelineGgasLineController.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/PipelineGgasLineController.java index e1e8d92..432f785 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/PipelineGgasLineController.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/PipelineGgasLineController.java @@ -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 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 ids){ + return R.ok(pipelineGgasLineService.enable(ids)); + } + + + @PostMapping("/disable") + @ApiOperation(value = "禁用") + @SaCheckPermission("pipelineGgasLine:disable") + public R disable(@Valid @RequestBody List ids){ + return R.ok(pipelineGgasLineService.disable(ids)); + } + + @GetMapping(value = "/datalog") + @ApiOperation(value="根据id查询LngBPngLine数据详细日志") + @SaCheckPermission("pipelineGgasLine:datalog") + public R datalog(@RequestParam Long id){ + List logs = dataService.findLogsByEntityId(UpdateLngBBankDto.class,id); + return R.ok(logs); + } } \ No newline at end of file diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/IPipeGasDownloadPointService.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/IPipeGasDownloadPointService.java index 1a86597..137a3cb 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/IPipeGasDownloadPointService.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/IPipeGasDownloadPointService.java @@ -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 { + + Boolean enable(List ids); + + Boolean disable(List ids); + + Long add(UpdateLngBStationPngDto dto); + + Long update(UpdateLngBStationPngDto dto); } diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/IPipelineGgasLineService.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/IPipelineGgasLineService.java index a89acc9..b4e2048 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/IPipelineGgasLineService.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/IPipelineGgasLineService.java @@ -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 { + + Boolean disable(List ids); + + Boolean enable(List ids); + + Long add(UpdateLngBPngLineDto dto); + + Long update(UpdateLngBPngLineDto dto); } diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/BankServiceImpl.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/BankServiceImpl.java index c0457e2..7469969 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/BankServiceImpl.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/BankServiceImpl.java @@ -38,16 +38,16 @@ public class BankServiceImpl extends ServiceImpl 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 imple public boolean enable(List 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 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)); } diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/CountryRegionServiceImpl.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/CountryRegionServiceImpl.java index 4aa6291..db41618 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/CountryRegionServiceImpl.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/CountryRegionServiceImpl.java @@ -61,7 +61,7 @@ public class CountryRegionServiceImpl extends ServiceImpl 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 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)); } diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/PipeGasDownloadPointServiceImpl.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/PipeGasDownloadPointServiceImpl.java index 9007d0a..ee39667 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/PipeGasDownloadPointServiceImpl.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/PipeGasDownloadPointServiceImpl.java @@ -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 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 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 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() + .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() + .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)); + } + } + } diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/PipelineGgasLineServiceImpl.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/PipelineGgasLineServiceImpl.java index fc7a7ea..305dd98 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/PipelineGgasLineServiceImpl.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/PipelineGgasLineServiceImpl.java @@ -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 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 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 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() + .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() + .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)); + } + } + }