From 0b50834d08f62c64e267c04136d141f64a2f7251 Mon Sep 17 00:00:00 2001 From: "shunyi.kuang" <846002312@qq.com> Date: Wed, 21 Jan 2026 15:06:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=97=A5=E8=AE=A1=E5=88=92=E7=AE=A1?= =?UTF-8?q?=E7=90=86-=E5=AE=A2=E6=88=B7=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dayPlan/dto/UpdateLngPngDemandDto.java | 15 +-- .../dayPlan/controller/DemandController.java | 49 ++++---- .../dayPlan/service/IDemandService.java | 7 +- .../service/impl/DemandServiceImpl.java | 119 ++++++++++++++---- 4 files changed, 134 insertions(+), 56 deletions(-) diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-api/src/main/java/com/xjrsoft/module/dayPlan/dto/UpdateLngPngDemandDto.java b/itc-pcitc-mdm/itc-pcitc-mdm-api/src/main/java/com/xjrsoft/module/dayPlan/dto/UpdateLngPngDemandDto.java index afdc97e..c774f45 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-api/src/main/java/com/xjrsoft/module/dayPlan/dto/UpdateLngPngDemandDto.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-api/src/main/java/com/xjrsoft/module/dayPlan/dto/UpdateLngPngDemandDto.java @@ -5,6 +5,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; +import com.fasterxml.jackson.annotation.JsonFormat; import com.pictc.annotations.datalog.JoinCaseType; import com.pictc.annotations.datalog.JoinType; import com.pictc.annotations.datalog.LogField; @@ -70,6 +71,7 @@ public class UpdateLngPngDemandDto implements Serializable { */ @LogField(name="计划日期",index=5) @ApiModelProperty("计划日期(次日计划为次日;当日计划为当日;同日、同客户、同销售合同交割点、同上载点、同供应商不能重复(仅检查最新版并去掉变更标识为删除的))") + @JsonFormat(pattern = "yyyy-MM-dd") private LocalDateTime datePlan; /** @@ -266,16 +268,5 @@ public class UpdateLngPngDemandDto implements Serializable { caseType = JoinCaseType.FULL, target = UpdateLngPngDemandPurDto.class, type = JoinType.MANY) private List lngPngDemandPurList; - /** - * lngPngApproPur - */ - /** - @ApiModelProperty("lngPngAppro子表") - @LogJoin(name = "lngPngAppro子表", - columns = { - @LogJoinColumn(field = "demandId",relatedField = "id", valueDirection = ValueDirectionType.RIGHT) - }, - caseType = JoinCaseType.FULL, target = UpdateLngPngApproPurDto.class, type = JoinType.MANY) - private List lngPngApproList; - **/ + } diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/controller/DemandController.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/controller/DemandController.java index 1069d0a..5ff8be7 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/controller/DemandController.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/controller/DemandController.java @@ -23,11 +23,15 @@ import com.alibaba.excel.support.ExcelTypeEnum; 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.DataLogTools; import com.xjrsoft.common.exception.BusinessException; import com.xjrsoft.common.model.result.R; import com.xjrsoft.common.page.PageOutput; import com.xjrsoft.common.utils.ExcelUtil; +import com.xjrsoft.module.common.db.utils.CommonCallUtils; import com.xjrsoft.module.datalog.service.DatalogService; import com.xjrsoft.module.datalog.vo.DataChangeLogVo; import com.xjrsoft.module.dayPlan.dto.LngPngDemandPageDto; @@ -38,7 +42,7 @@ import com.xjrsoft.module.dayPlan.service.IDemandService; import com.xjrsoft.module.dayPlan.vo.LngPngDemandPageVo; import com.xjrsoft.module.dayPlan.vo.LngPngDemandPurVo; import com.xjrsoft.module.dayPlan.vo.LngPngDemandVo; - +import com.pictc.utils.StringUtils; import cn.dev33.satoken.annotation.SaCheckPermission; import cn.hutool.core.bean.BeanUtil; import io.swagger.annotations.Api; @@ -66,8 +70,8 @@ public class DemandController { @ApiOperation(value="LngPngDemand列表(分页)") @SaCheckPermission("demand:list") public R page(@Valid LngPngDemandPageDto dto){ - - return R.ok(demandService.queryPage(dto)); + return null; + //return R.ok(demandService.queryPage(dto)); } @GetMapping(value = "/info") @@ -99,8 +103,11 @@ public class DemandController { @Override public UpdateLngPngDemandDto after(DataOperationContent content) { - - return null; + String msg = CommonCallUtils.saveAfter(content.getTableName(),content.getIdValue()); + if (StringUtils.isNotEmpty(msg)) { + throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg)); + } + return content.getObj(); } })); @@ -119,12 +126,23 @@ public class DemandController { @Override public UpdateLngPngDemandDto after(DataOperationContent content) { - - return null; + String msg = CommonCallUtils.saveAfter(content.getTableName(),content.getIdValue()); + if (StringUtils.isNotEmpty(msg)) { + throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg)); + } + return content.getObj(); } })); } + @PostMapping(value="/saveAndSubmit") + @ApiOperation(value = "保存并提交LngPngDemand") + //@SaCheckPermission("demand:edit") + public R saveAndSubmit(@Valid @RequestBody UpdateLngPngDemandDto dto){ + demandService.saveAndSubmit(dto); + return R.ok(); + } + @PostMapping(value="/toChange") @ApiOperation(value = "变更LngPngDemand") //@SaCheckPermission("demand:toChange") @@ -230,20 +248,9 @@ public class DemandController { @PostMapping(value="/submit") @ApiOperation(value = "提交LngPngDemand") //@SaCheckPermission("demand:edit") - public R submit(@Valid @RequestBody UpdateLngPngDemandDto dto){ - return R.ok(dataService.updateById(dto,new DataOperationListener() { - - @Override - public UpdateLngPngDemandDto before(DataOperationContent content) { - return null; - } - - @Override - public UpdateLngPngDemandDto after(DataOperationContent content) { - - return null; - } - })); + public R submit(@Valid @RequestBody List ids){ + demandService.submit(ids); + return R.ok(); } @PostMapping("/import") diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/IDemandService.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/IDemandService.java index 0816faa..cb794a0 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/IDemandService.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/IDemandService.java @@ -10,6 +10,7 @@ import com.github.yulichang.extension.mapping.base.MPJRelationService; import com.xjrsoft.common.model.result.R; import com.xjrsoft.common.page.PageOutput; import com.xjrsoft.module.dayPlan.dto.LngPngDemandPageDto; +import com.xjrsoft.module.dayPlan.dto.UpdateLngPngDemandDto; import com.xjrsoft.module.dayPlan.entity.LngPngDemand; import com.xjrsoft.module.dayPlan.vo.LngPngDemandPageVo; import com.xjrsoft.module.dayPlan.vo.LngPngDemandVo; @@ -23,7 +24,7 @@ import com.xjrsoft.module.dayPlan.vo.LngPngDemandVo; public interface IDemandService extends MPJBaseService, MPJDeepService, MPJRelationService { - PageOutput queryPage(LngPngDemandPageDto dto); + //PageOutput queryPage(LngPngDemandPageDto dto); LngPngDemandVo getInfoById(Long id); @@ -34,6 +35,10 @@ public interface IDemandService extends MPJBaseService, MPJDeepSer void withdraw(@Valid List ids); void deleteByIds(@Valid List ids); + + void submit(@Valid List ids); + + void saveAndSubmit(@Valid UpdateLngPngDemandDto dto); } diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/impl/DemandServiceImpl.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/impl/DemandServiceImpl.java index aaa4dfa..193ca00 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/impl/DemandServiceImpl.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/impl/DemandServiceImpl.java @@ -2,6 +2,7 @@ package com.xjrsoft.module.dayPlan.service.impl; import java.lang.reflect.Field; import java.math.BigDecimal; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Comparator; import java.util.List; @@ -9,22 +10,20 @@ import java.util.stream.Collectors; import javax.validation.Valid; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.yulichang.base.MPJBaseServiceImpl; 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.DataLogTools; +import com.pictc.utils.StringUtils; import com.xjrsoft.common.exception.BusinessException; -import com.xjrsoft.common.page.ConventPage; -import com.xjrsoft.common.page.PageOutput; import com.xjrsoft.module.datalog.service.DatalogService; -import com.xjrsoft.module.dayPlan.dto.LngPngDemandPageDto; import com.xjrsoft.module.dayPlan.dto.UpdateLngPngApproDto; import com.xjrsoft.module.dayPlan.dto.UpdateLngPngDemandDto; import com.xjrsoft.module.dayPlan.entity.LngPngAppro; @@ -35,7 +34,6 @@ import com.xjrsoft.module.dayPlan.mapper.LngPngDemandMapper; import com.xjrsoft.module.dayPlan.mapper.LngPngDemandPurMapper; import com.xjrsoft.module.dayPlan.service.IDemandService; import com.xjrsoft.module.dayPlan.vo.LngPngDemandChangeDetailVo; -import com.xjrsoft.module.dayPlan.vo.LngPngDemandPageVo; import com.xjrsoft.module.dayPlan.vo.LngPngDemandVo; import cn.hutool.core.bean.BeanUtil; @@ -60,21 +58,7 @@ public class DemandServiceImpl extends MPJBaseServiceImpl queryPage(LngPngDemandPageDto dto) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper - .and(StringUtils.isNotBlank(dto.getKName()), r -> - r.like("k.k_no", dto.getKName()) - .or() - .like("k.k_name", dto.getKName()) - ) - .like(StringUtils.isNotBlank(dto.getPointDelyName()), "sp.full_name", dto.getPointDelyName()) - .eq("d.last_ver_sign", "Y"); - IPage page = this.baseMapper.queryPage(ConventPage.getPage(dto), queryWrapper); - PageOutput pageOutput = ConventPage.getPageOutput(page, LngPngDemandPageVo.class); - return pageOutput; - } + @Override public LngPngDemandVo getInfoById(Long id) { @@ -306,5 +290,96 @@ public class DemandServiceImpl extends MPJBaseServiceImpl ids) { + List tempList = Lists.newArrayList(); + //List ids = dtoList.stream().map(UpdateLngPngDemandDto::getId).collect(Collectors.toList()); + for(Long id:ids) { + LngPngDemand lngPngDemand = this.getByIdDeep(id); + if (lngPngDemand == null) { + throw new BusinessException(BusinessCode.of(10500,"找不到此数据!")); + + } + if(!"WTJ".equals(lngPngDemand.getApproCode()) || !"YBH".equals(lngPngDemand.getApproCode()) ) { + throw new BusinessException(BusinessCode.of(10500,"审批状态变化,不能提交")); + } + + lngPngDemand.setApproCode("SPZ"); + lngPngDemand.setTimeSubmit(LocalDateTime.now()); + tempList.add(BeanUtil.copyProperties(lngPngDemand,UpdateLngPngDemandDto.class)); + } + dataService.insertBatch(tempList,new DataOperationListener() { + + @Override + public UpdateLngPngDemandDto before(DataOperationContent content) { + return null; + } + + @Override + public UpdateLngPngDemandDto after(DataOperationContent content) { + String sql = StringUtils.format("{? = call pc_{0}.f_submit(?)}", + content.getTableName()); + List 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 void saveAndSubmit(@Valid UpdateLngPngDemandDto dto) { + dto.setApproCode("SPZ"); + dto.setTimeSubmit(LocalDateTime.now()); + if(dto.getId() != null) { + LngPngDemand lngPngDemand = this.getById(dto.getId()); + if (lngPngDemand == null) { + throw new BusinessException(BusinessCode.of(10500,"找不到此数据!")); + + } + if(!"WTJ".equals(lngPngDemand.getApproCode()) || !"YBH".equals(lngPngDemand.getApproCode()) ) { + throw new BusinessException(BusinessCode.of(10500,"审批状态变化,不能提交")); + } + + + } + dataService.insert(dto,new DataOperationListener() { + + @Override + public UpdateLngPngDemandDto before(DataOperationContent content) { + return null; + } + + @Override + public UpdateLngPngDemandDto after(DataOperationContent content) { + String sql = StringUtils.format("{? = call pc_{0}.f_save_submit(?,?)}", + content.getTableName()); + + List params = Lists.newArrayList(); + JdbcParam outParam = JdbcParam.ofString(null).setOut(true); + params.add(outParam); + params.add(JdbcParam.ofLong(content.getIdValue())); + if(dto.getId() != null) { + params.add(JdbcParam.ofString("U")); + }else { + params.add(JdbcParam.ofString("I")); + } + 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(); + } + }); + } + } From f5f584981a6aaf5ee3487d5909fc8632e2b8dc9e Mon Sep 17 00:00:00 2001 From: "shunyi.kuang" <846002312@qq.com> Date: Thu, 22 Jan 2026 16:13:38 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=97=A5=E8=AE=A1=E5=88=92=E7=AE=A1?= =?UTF-8?q?=E7=90=86-=E5=AE=A2=E6=88=B7=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/dayPlan/vo/LngPngDemandVo.java | 7 +++- .../dayPlan/controller/DemandController.java | 40 ++++++++++++++----- .../dayPlan/mapper/LngPngDemandMapper.java | 11 +++++ .../service/impl/DemandServiceImpl.java | 20 +++++++--- 4 files changed, 60 insertions(+), 18 deletions(-) diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-api/src/main/java/com/xjrsoft/module/dayPlan/vo/LngPngDemandVo.java b/itc-pcitc-mdm/itc-pcitc-mdm-api/src/main/java/com/xjrsoft/module/dayPlan/vo/LngPngDemandVo.java index 503290c..8b8491a 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-api/src/main/java/com/xjrsoft/module/dayPlan/vo/LngPngDemandVo.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-api/src/main/java/com/xjrsoft/module/dayPlan/vo/LngPngDemandVo.java @@ -83,6 +83,8 @@ public class LngPngDemandVo extends com.xjrsoft.common.model.base.BaseModel{ @ApiModelProperty("合同-主信息主键(销售)(lng_contract)") private Long ksId; + private String kName; + /** * 合同-国内销售-管道气-交割点主键(lng_contract_sales_png_point) @@ -95,7 +97,9 @@ public class LngPngDemandVo extends com.xjrsoft.common.model.base.BaseModel{ * 交割点编码 */ @ApiModelProperty("交割点编码") + @Trans(type = TransType.LNG_STATION, transToFieldName = "pointDelyName") private String pointDelyCode; + private String pointDelyName; /** @@ -214,8 +218,9 @@ public class LngPngDemandVo extends com.xjrsoft.common.model.base.BaseModel{ * 审批状态(待提交/审批中/已审批/已驳回) */ @ApiModelProperty("审批状态(待提交/审批中/已审批/已驳回)") + @Trans(type = TransType.DIC, id = "1990669393069129729", transToFieldName = "approName") private String approCode; - + private String approName; /** * 提交时间 diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/controller/DemandController.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/controller/DemandController.java index 5ff8be7..fcf37f5 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/controller/DemandController.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/controller/DemandController.java @@ -103,11 +103,19 @@ public class DemandController { @Override public UpdateLngPngDemandDto after(DataOperationContent content) { - String msg = CommonCallUtils.saveAfter(content.getTableName(),content.getIdValue()); - if (StringUtils.isNotEmpty(msg)) { - throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg)); - } - return content.getObj(); + String sql = StringUtils.format("{? = call pc_{0}.f_save(?,?)}", + content.getTableName()); + List params = Lists.newArrayList(); + JdbcParam outParam = JdbcParam.ofString(null).setOut(true); + params.add(outParam); + params.add(JdbcParam.ofLong(content.getIdValue())); + params.add(JdbcParam.ofString("I")); + 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(); } })); @@ -117,8 +125,10 @@ public class DemandController { @ApiOperation(value = "编辑LngPngDemand") @SaCheckPermission("demand:edit") public R update(@Valid @RequestBody UpdateLngPngDemandDto dto){ + + dto.setOrgId(dto.getId()); return R.ok(dataService.updateById(dto,new DataOperationListener() { - + @Override public UpdateLngPngDemandDto before(DataOperationContent content) { return null; @@ -126,11 +136,19 @@ public class DemandController { @Override public UpdateLngPngDemandDto after(DataOperationContent content) { - String msg = CommonCallUtils.saveAfter(content.getTableName(),content.getIdValue()); - if (StringUtils.isNotEmpty(msg)) { - throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg)); - } - return content.getObj(); + String sql = StringUtils.format("{? = call pc_{0}.f_save(?,?)}", + content.getTableName()); + List params = Lists.newArrayList(); + JdbcParam outParam = JdbcParam.ofString(null).setOut(true); + params.add(outParam); + params.add(JdbcParam.ofLong(content.getIdValue())); + params.add(JdbcParam.ofString("U")); + 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(); } })); } diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/mapper/LngPngDemandMapper.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/mapper/LngPngDemandMapper.java index 93186d4..ea494ff 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/mapper/LngPngDemandMapper.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/mapper/LngPngDemandMapper.java @@ -1,5 +1,7 @@ package com.xjrsoft.module.dayPlan.mapper; +import java.util.List; + import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -11,7 +13,9 @@ import com.baomidou.mybatisplus.core.toolkit.Constants; import com.github.yulichang.base.MPJBaseMapper; import com.xjrsoft.module.dayPlan.dto.LngPngDemandPageDto; import com.xjrsoft.module.dayPlan.entity.LngPngDemand; +import com.xjrsoft.module.dayPlan.vo.LngPngApproVo; import com.xjrsoft.module.dayPlan.vo.LngPngDemandPageVo; +import com.xjrsoft.module.dayPlan.vo.LngPngDemandVo; /** * @title: mapper @@ -43,4 +47,11 @@ public interface LngPngDemandMapper extends MPJBaseMapper,BaseMapp " JOIN lng_png_approval a ON a.appro_id=pa.id " + " WHERE d.id = #{id}") Long getApprovedCount(@Param("id") Long id); + + + @Select("SELECT d.*,k.k_name"+ + " FROM lng_png_demand d" + + " LEFT JOIN lng_contract k ON k.id=d.ks_id" + + " WHERE d.id = #{id}") + LngPngDemandVo getInfoBygId(@Param("id") Long id); } diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/impl/DemandServiceImpl.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/impl/DemandServiceImpl.java index 193ca00..eecf26f 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/impl/DemandServiceImpl.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/impl/DemandServiceImpl.java @@ -34,6 +34,7 @@ import com.xjrsoft.module.dayPlan.mapper.LngPngDemandMapper; import com.xjrsoft.module.dayPlan.mapper.LngPngDemandPurMapper; import com.xjrsoft.module.dayPlan.service.IDemandService; import com.xjrsoft.module.dayPlan.vo.LngPngDemandChangeDetailVo; +import com.xjrsoft.module.dayPlan.vo.LngPngDemandPurVo; import com.xjrsoft.module.dayPlan.vo.LngPngDemandVo; import cn.hutool.core.bean.BeanUtil; @@ -62,11 +63,16 @@ public class DemandServiceImpl extends MPJBaseServiceImpl queryPurWrapper = new LambdaQueryWrapper<>(); + queryPurWrapper.eq(LngPngDemandPur::getDemandId,id); + queryPurWrapper.orderByAsc(LngPngDemandPur::getSort); + List purList = demandPurMapper.selectList(queryPurWrapper); + lngPngDemandVo.setLngPngDemandPurList(BeanUtil.copyToList(purList, LngPngDemandPurVo.class)); + return lngPngDemandVo; } @Override @@ -251,7 +257,7 @@ public class DemandServiceImpl extends MPJBaseServiceImpl queryWrapper = new LambdaQueryWrapper<>(); @@ -300,7 +306,7 @@ public class DemandServiceImpl extends MPJBaseServiceImpl content) { + String sql = StringUtils.format("{? = call pc_{0}.f_submit(?)}", content.getTableName()); List params = Lists.newArrayList(); @@ -344,7 +351,8 @@ public class DemandServiceImpl extends MPJBaseServiceImpl Date: Thu, 22 Jan 2026 17:24:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/datalog/vo/CompareResultVo.java | 28 +++++ .../java/com/pictc/utils/ObjectDiffUtils.java | 116 ++++++++++++++++++ .../dayPlan/service/IPngApproService.java | 4 +- .../service/impl/PngApproServiceImpl.java | 32 +++-- .../module/sales/entity/LngCustomerGroup.java | 7 +- 5 files changed, 171 insertions(+), 16 deletions(-) create mode 100644 itc-pcitc-dependencies/itc-pcitc-dependencies-api/src/main/java/com/xjrsoft/module/datalog/vo/CompareResultVo.java create mode 100644 itc-pcitc-dependencies/itc-pcitc-dependencies-service/src/main/java/com/pictc/utils/ObjectDiffUtils.java diff --git a/itc-pcitc-dependencies/itc-pcitc-dependencies-api/src/main/java/com/xjrsoft/module/datalog/vo/CompareResultVo.java b/itc-pcitc-dependencies/itc-pcitc-dependencies-api/src/main/java/com/xjrsoft/module/datalog/vo/CompareResultVo.java new file mode 100644 index 0000000..ff0fb7d --- /dev/null +++ b/itc-pcitc-dependencies/itc-pcitc-dependencies-api/src/main/java/com/xjrsoft/module/datalog/vo/CompareResultVo.java @@ -0,0 +1,28 @@ +package com.xjrsoft.module.datalog.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class CompareResultVo { + + /** + * 最新版本 + */ + @ApiModelProperty("最新版本") + private T newBean; + + /** + * 旧版本 + */ + @ApiModelProperty("旧版本") + private T oldBean; + + /** + * 比对结果 + */ + @ApiModelProperty("比对结果") + private List diffResultList; +} diff --git a/itc-pcitc-dependencies/itc-pcitc-dependencies-service/src/main/java/com/pictc/utils/ObjectDiffUtils.java b/itc-pcitc-dependencies/itc-pcitc-dependencies-service/src/main/java/com/pictc/utils/ObjectDiffUtils.java new file mode 100644 index 0000000..c4db674 --- /dev/null +++ b/itc-pcitc-dependencies/itc-pcitc-dependencies-service/src/main/java/com/pictc/utils/ObjectDiffUtils.java @@ -0,0 +1,116 @@ +package com.pictc.utils; + +import org.apache.commons.collections4.CollectionUtils; + +import java.lang.reflect.Field; +import java.util.*; + +/** + * 对象差异比较工具类 + * 支持嵌套对象和List集合的比较 + */ +public class ObjectDiffUtils { + + /** + * 比较两个对象并返回差异信息 + * @param obj1 第一个对象 + * @param obj2 第二个对象 + * @param 对象类型 + * @return 差异结果列表 + */ + public static List compare(T obj1, T obj2) { + List diffs = new ArrayList<>(); + if (obj1 == null || obj2 == null) { + return diffs; + } + try { + compareFields(obj1, obj2, diffs); + } catch (Exception e) { + throw new RuntimeException("Failed to compare objects", e); + } + return diffs; + } + + /** + * 递归比较对象字段 + */ + private static void compareFields(Object obj1, Object obj2, List diffs) + throws IllegalAccessException { + Class clazz = obj1.getClass(); + // 获取所有字段(包括私有字段) + Field[] fields = getAllFields(clazz); + for (Field field : fields) { + field.setAccessible(true); + Object value1 = field.get(obj1); + Object value2 = field.get(obj2); + String fieldName = field.getName(); + // 检查字段类型 + Class fieldType = field.getType(); + // 如果是List类型 + if (List.class.isAssignableFrom(fieldType)) { + compareLists(value1, value2, fieldName, diffs); + } + // 如果是Map类型(可选扩展) + else if (Map.class.isAssignableFrom(fieldType)) { + compareMaps(value1, value2, fieldName, diffs); + } + // 基本类型、String、包装类型等 + else { + compareBasicValues(value1, value2, fieldName, diffs); + } + } + } + + /** + * 比较两个List + */ + private static void compareLists(Object list1, Object list2, String fieldName, List diffs) { + List l1 = (List) list1; + List l2 = (List) list2; + if (l1 == null || l2 == null) { + return; + } + // 比较List大小 + if (l1.size() != l2.size()) { + diffs.add(fieldName); + return; + } + // 比较List中的每个元素 + for (int i = 0; i < l1.size(); i++) { + List result = compare(l1.get(i), l2.get(i)); + if (CollectionUtils.isNotEmpty(result)) { + for (String s : result) { + diffs.add(fieldName + "["+ i +"]." + s); + } + } + } + } + + /** + * 比较两个Map(可选功能) + */ + private static void compareMaps(Object map1, Object map2, String path, List diffs) { + // Map比较的实现,可根据需要扩展 + } + + /** + * 比较基本值 + */ + private static void compareBasicValues(Object value1, Object value2, String fieldName, List diffs) { + if (!Objects.equals(value1, value2)) { + diffs.add(fieldName); + } + } + + /** + * 获取类及其父类的所有字段 + */ + private static Field[] getAllFields(Class clazz) { + List fields = new ArrayList<>(); + while (clazz != null && clazz != Object.class) { + fields.addAll(Arrays.asList(clazz.getDeclaredFields())); + clazz = clazz.getSuperclass(); + } + return fields.toArray(new Field[0]); + } +} \ No newline at end of file diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/IPngApproService.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/IPngApproService.java index 9c0d84d..725d962 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/IPngApproService.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/IPngApproService.java @@ -5,6 +5,7 @@ import com.github.yulichang.extension.mapping.base.MPJDeepService; import com.github.yulichang.extension.mapping.base.MPJRelationService; import com.xjrsoft.common.page.PageOutput; import com.xjrsoft.module.approve.ApproveDto; +import com.xjrsoft.module.datalog.vo.CompareResultVo; import com.xjrsoft.module.dayPlan.dto.LngPngApproPageDto; import com.xjrsoft.module.dayPlan.dto.UpdateLngPngApproDto; import com.xjrsoft.module.dayPlan.entity.LngPngAppro; @@ -12,7 +13,6 @@ import com.xjrsoft.module.dayPlan.vo.LngPngApproPageVo; import com.xjrsoft.module.dayPlan.vo.LngPngApproVo; import javax.validation.Valid; -import java.util.List; /** * @title: service @@ -33,5 +33,5 @@ public interface IPngApproService extends MPJBaseService, MPJDeepSe void approveJSZ(@Valid ApproveDto dto); - List compare(Long orgId); + CompareResultVo compare(Long orgId); } diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/impl/PngApproServiceImpl.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/impl/PngApproServiceImpl.java index 9b9e81b..9973eca 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/impl/PngApproServiceImpl.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/service/impl/PngApproServiceImpl.java @@ -12,11 +12,13 @@ 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.ObjectDiffUtils; import com.xjrsoft.common.constant.GlobalConstant; import com.xjrsoft.common.exception.BusinessException; import com.xjrsoft.common.page.ConventPage; import com.xjrsoft.common.page.PageOutput; import com.xjrsoft.module.approve.ApproveDto; +import com.xjrsoft.module.datalog.vo.CompareResultVo; import com.xjrsoft.module.dayPlan.dto.LngPngApproPageDto; import com.xjrsoft.module.dayPlan.dto.UpdateLngPngApproDto; import com.xjrsoft.module.dayPlan.dto.UpdateLngPngApproPurDto; @@ -36,6 +38,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; +import java.time.LocalDateTime; import java.util.List; /** @@ -81,7 +84,7 @@ public class PngApproServiceImpl extends MPJBaseServiceImpl compare(Long orgId) { + public CompareResultVo compare(Long orgId) { List voList = this.baseMapper.getListByOrgId(orgId); if(CollectionUtils.isEmpty(voList)) { throw new BusinessException(BusinessCode.of(10500,"找不到此数据")); @@ -90,7 +93,16 @@ public class PngApproServiceImpl extends MPJBaseServiceImpl lngPngApproPurList = this.baseMapper.queryLngPngApproPurList(vo.getId()); vo.setLngPngApproPurList(lngPngApproPurList); } - return voList; + CompareResultVo vo = new CompareResultVo<>(); + LngPngApproVo newBean = voList.get(0); + vo.setNewBean(newBean); + if (voList.size() > 1) { + LngPngApproVo oldBean = voList.get(1); + List diffResultList = ObjectDiffUtils.compare(newBean, oldBean); + vo.setOldBean(oldBean); + vo.setDiffResultList(diffResultList); + } + return vo; } @Override @@ -170,15 +182,15 @@ public class PngApproServiceImpl extends MPJBaseServiceImpl params = Lists.newArrayList(); JdbcParam outParam = JdbcParam.ofString(null).setOut(true); params.add(outParam); params.add(JdbcParam.ofString(user.getStaCode())); - params.add(JdbcParam.ofLocalDateTime(lngPngAppro.getDatePlan())); + params.add(JdbcParam.ofLocalDateTime(datePlan)); params.add(JdbcParam.ofString(dto.getResult())); params.add(JdbcParam.ofString(dto.getRemark())); params.add(JdbcParam.ofLong(user.getId())); @@ -202,15 +214,15 @@ public class PngApproServiceImpl extends MPJBaseServiceImpl params = Lists.newArrayList(); JdbcParam outParam = JdbcParam.ofString(null).setOut(true); params.add(outParam); params.add(JdbcParam.ofString(user.getStaCode())); - params.add(JdbcParam.ofLocalDateTime(lngPngAppro.getDatePlan())); + params.add(JdbcParam.ofLocalDateTime(datePlan)); params.add(JdbcParam.ofString(dto.getResult())); params.add(JdbcParam.ofString(dto.getRemark())); params.add(JdbcParam.ofLong(user.getId())); diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/sales/entity/LngCustomerGroup.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/sales/entity/LngCustomerGroup.java index 419038a..90cdd82 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/sales/entity/LngCustomerGroup.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/sales/entity/LngCustomerGroup.java @@ -1,9 +1,6 @@ package com.xjrsoft.module.sales.entity; -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.*; import com.github.yulichang.annotation.EntityMapping; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -52,11 +49,13 @@ public class LngCustomerGroup implements Serializable { * 起始日期 */ @ApiModelProperty("起始日期") + @TableField(updateStrategy = FieldStrategy.IGNORED) private LocalDateTime dateFrom; /** * 结束日期 */ @ApiModelProperty("结束日期") + @TableField(updateStrategy = FieldStrategy.IGNORED) private LocalDateTime dateTo; /** * 备注