From 5ec3cedadfe73e5a6f869e249b1bff7ddbb82862 Mon Sep 17 00:00:00 2001 From: "shunyi.kuang" <846002312@qq.com> Date: Fri, 23 Jan 2026 11:25:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E8=AE=A1=E5=88=92=E7=AE=A1=E7=90=86-?= =?UTF-8?q?=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/controller/DemandController.java | 15 +- .../dayPlan/entity/LngPngDemandPur.java | 39 +-- .../dayPlan/service/IDemandService.java | 3 +- .../service/impl/DemandServiceImpl.java | 230 ++++++------------ 4 files changed, 96 insertions(+), 191 deletions(-) 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 fcf37f5..1d0cc0f 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 @@ -45,6 +45,7 @@ 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 cn.hutool.core.util.IdUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; @@ -94,6 +95,8 @@ public class DemandController { @ApiOperation(value = "新增LngPngDemand") @SaCheckPermission("demand:add") public R add(@Valid @RequestBody UpdateLngPngDemandDto dto){ + dto.setId(IdUtil.getSnowflakeNextId()); + dto.setOrgId(dto.getId()); return R.ok(dataService.insert(dto,new DataOperationListener() { @Override @@ -161,15 +164,15 @@ public class DemandController { return R.ok(); } - @PostMapping(value="/toChange") + @GetMapping(value="/toChange") @ApiOperation(value = "变更LngPngDemand") //@SaCheckPermission("demand:toChange") public R toChange(@Valid @RequestParam Long id){ - LngPngDemand lngPngDemand = demandService.getByIdDeep(id); - if (lngPngDemand == null) { + LngPngDemandVo res = demandService.getInfoById(id); + if (res == null) { return R.error("找不到此数据!"); } - LngPngDemandVo res = BeanUtil.toBean(lngPngDemand, LngPngDemandVo.class); + //LngPngDemandVo res = BeanUtil.toBean(lngPngDemand, LngPngDemandVo.class); res.setId(null); res.setAlterSign("U"); res.setApproCode("WTJ"); @@ -196,7 +199,7 @@ public class DemandController { return R.ok(res); } - @PostMapping(value="/cancel") + @GetMapping(value="/cancel") @ApiOperation(value = "取消LngPngDemand") //@SaCheckPermission("demand:cancel") public R cancel(@Valid @RequestParam Long id){ @@ -250,7 +253,7 @@ public class DemandController { @PostMapping(value="/withdraw") @ApiOperation(value = "撤回LngPngDemand") //@SaCheckPermission("demand:cancel") - public R withdraw(@Valid @RequestParam List ids){ + public R withdraw(@Valid @RequestBody List ids){ demandService.withdraw(ids); return R.ok(); } diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/entity/LngPngDemandPur.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/entity/LngPngDemandPur.java index 45ee907..2b68286 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/entity/LngPngDemandPur.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/dayPlan/entity/LngPngDemandPur.java @@ -1,21 +1,18 @@ package com.xjrsoft.module.dayPlan.entity; +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; + import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldStrategy; import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableLogic; -import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.Version; -import com.github.yulichang.annotation.EntityMapping; +import com.baomidou.mybatisplus.annotation.TableName; + import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.io.Serializable; -import java.time.LocalTime; -import java.time.LocalDateTime; -import java.math.BigDecimal; -import java.util.List; /** @@ -46,9 +43,6 @@ public class LngPngDemandPur implements Serializable { * 日计划-管道气-客户需求主键 */ @ApiModelProperty("日计划-管道气-客户需求主键") - - - @TableField(updateStrategy = FieldStrategy.IGNORED) private Long demandId; @@ -62,9 +56,6 @@ public class LngPngDemandPur implements Serializable { * 采购合同-主信息主键 */ @ApiModelProperty("采购合同-主信息主键") - - - @TableField(updateStrategy = FieldStrategy.IGNORED) private Long kpId; @@ -72,9 +63,6 @@ public class LngPngDemandPur implements Serializable { * 合同-国内采购-管道气-上载点主键 */ @ApiModelProperty("合同-国内采购-管道气-上载点主键") - - - @TableField(updateStrategy = FieldStrategy.IGNORED) private Long kpppId; @@ -94,9 +82,6 @@ public class LngPngDemandPur implements Serializable { * 比值(方/吉焦) */ @ApiModelProperty("比值(方/吉焦)") - - - @TableField(updateStrategy = FieldStrategy.IGNORED) private BigDecimal rateM3Gj; @@ -104,9 +89,6 @@ public class LngPngDemandPur implements Serializable { * 日指定量(吉焦)(客户填报) */ @ApiModelProperty("日指定量(吉焦)(客户填报)") - - - @TableField(updateStrategy = FieldStrategy.IGNORED) private BigDecimal qtyDemandGj; @@ -154,9 +136,6 @@ public class LngPngDemandPur implements Serializable { * 创建人id */ @ApiModelProperty("创建人id") - - - @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.IGNORED) private Long createUserId; @@ -192,9 +171,6 @@ public class LngPngDemandPur implements Serializable { * 部门id */ @ApiModelProperty("部门id") - - - @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.IGNORED) private Long deptId; @@ -202,9 +178,6 @@ public class LngPngDemandPur implements Serializable { * 数据权限id */ @ApiModelProperty("数据权限id") - - - @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.IGNORED) private Long ruleUserId; 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 cb794a0..9e287ae 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 @@ -9,6 +9,7 @@ import com.github.yulichang.extension.mapping.base.MPJDeepService; 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.datalog.vo.CompareResultVo; import com.xjrsoft.module.dayPlan.dto.LngPngDemandPageDto; import com.xjrsoft.module.dayPlan.dto.UpdateLngPngDemandDto; import com.xjrsoft.module.dayPlan.entity.LngPngDemand; @@ -28,7 +29,7 @@ public interface IDemandService extends MPJBaseService, MPJDeepSer LngPngDemandVo getInfoById(Long id); - List compare(@Valid Long id); + CompareResultVo compare(@Valid Long id); Long selectApprovedCount(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 eecf26f..9b4ad69 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 @@ -10,6 +10,7 @@ import java.util.stream.Collectors; import javax.validation.Valid; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -21,9 +22,11 @@ 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.ObjectDiffUtils; import com.pictc.utils.StringUtils; import com.xjrsoft.common.exception.BusinessException; import com.xjrsoft.module.datalog.service.DatalogService; +import com.xjrsoft.module.datalog.vo.CompareResultVo; import com.xjrsoft.module.dayPlan.dto.UpdateLngPngApproDto; import com.xjrsoft.module.dayPlan.dto.UpdateLngPngDemandDto; import com.xjrsoft.module.dayPlan.entity.LngPngAppro; @@ -33,11 +36,14 @@ import com.xjrsoft.module.dayPlan.mapper.LngPngApproMapper; 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.LngPngApproPurVo; +import com.xjrsoft.module.dayPlan.vo.LngPngApproVo; 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; +import cn.hutool.core.util.IdUtil; import lombok.AllArgsConstructor; import shade.powerjob.com.google.common.collect.Lists; @@ -81,133 +87,31 @@ public class DemandServiceImpl extends MPJBaseServiceImpl compare(@Valid Long id) { - List list = Lists.newArrayList(); - List mainChangeList = Lists.newArrayList(); - List subListChangeList = Lists.newArrayList(); - LngPngDemand current = this.getByIdDeep(id); - if(current != null) { - LngPngDemandVo currentVo = BeanUtil.toBean(current, LngPngDemandVo.class); - list.add(currentVo); - List currentPurList = current.getLngPngDemandPurList(); - currentPurList = currentPurList.stream() - .sorted(Comparator.comparing(LngPngDemandPur::getSort)) - .collect(Collectors.toList()); - + public CompareResultVo compare(@Valid Long id) { + List voList = Lists.newArrayList(); + LngPngDemandVo currentVo = this.getInfoById(id); + voList.add(currentVo); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(LngPngDemand::getOrgId, current.getOrgId()); - queryWrapper.eq(LngPngDemand::getVerNo, current.getVerNo()-1); + queryWrapper.eq(LngPngDemand::getOrgId, currentVo.getOrgId()); + queryWrapper.eq(LngPngDemand::getVerNo, currentVo.getVerNo()-1); LngPngDemand last = this.baseMapper.selectOne(queryWrapper); if(last != null) { - compareMain(current,last,mainChangeList); - LambdaQueryWrapper queryPurWrapper = new LambdaQueryWrapper<>(); - queryPurWrapper.eq(LngPngDemandPur::getDemandId,last.getId()); - queryPurWrapper.orderByAsc(LngPngDemandPur::getSort); - List lastPurList = demandPurMapper.selectList(queryPurWrapper); - //增加了item - if(currentPurList.size() >= lastPurList.size()) { - for(int i=0;i vo = new CompareResultVo<>(); + LngPngDemandVo newBean = voList.get(0); + vo.setNewBean(newBean); + if (voList.size() > 1) { + LngPngDemandVo oldBean = voList.get(1); + List diffResultList = ObjectDiffUtils.compare(newBean, oldBean); + vo.setOldBean(oldBean); + vo.setDiffResultList(diffResultList); + } + return vo; } + - private void compareMain(LngPngDemand current, LngPngDemand last,List changeList) { - - String[] compareFields = {"datePlan","kName","pointDelyCode","qtyDemandGj","qtyDemandM3","priceSalesGj", - "priceSalesM3","reply","note"}; - for (String fieldName : compareFields) { - try { - Field field = LngPngDemand.class.getDeclaredField(fieldName); - - field.setAccessible(true); - - Object currentValue = field.get(current); - Object lastValue = field.get(last); - - if (currentValue == null && lastValue == null) { - - }else if(currentValue != null && lastValue != null){ - if(currentValue instanceof BigDecimal) { - if(!formatValue(currentValue).equals(formatValue(currentValue))){ - changeList.add(genNewChange(fieldName,-1)); - } - }else if(!currentValue.toString().equals(lastValue.toString())) { - changeList.add(genNewChange(fieldName,-1)); - } - }else { - changeList.add(genNewChange(fieldName,-1)); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - private void compareSubList(LngPngDemandPur current, LngPngDemandPur last,List changeList,int index) { - - String[] compareFields = {"suCode","pointUpCode","qtyDemandGj","qtyDemandM3", - "qtySalesGj","qtySalesM3","note"}; - for (String fieldName : compareFields) { - try { - Field field = LngPngDemandPur.class.getDeclaredField(fieldName); - - field.setAccessible(true); - Object currentValue = field.get(current); - Object lastValue = field.get(last); - - if (currentValue == null && lastValue == null) { - - }else if(currentValue != null && lastValue != null){ - if(currentValue instanceof BigDecimal) { - if(!formatValue(currentValue).equals(formatValue(currentValue))){ - changeList.add(genNewChange(fieldName,index)); - } - }else if(!currentValue.toString().equals(lastValue.toString())) { - changeList.add(genNewChange(fieldName,index)); - } - }else { - changeList.add(genNewChange(fieldName,index)); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - - private static String formatValue(Object value) { - if (value instanceof BigDecimal) { - return ((BigDecimal) value).toPlainString(); - } - if (value instanceof LocalDateTime) { - return ((BigDecimal) value).toPlainString(); - } - return value != null ? value.toString() : ""; - } - - - private LngPngDemandChangeDetailVo genNewChange(String fieldName,int index) { - LngPngDemandChangeDetailVo changeDetail = new LngPngDemandChangeDetailVo(); - changeDetail.setChangeFlag(true); - changeDetail.setAlterSign("U"); - changeDetail.setFiledName(fieldName); - changeDetail.setSubListIndex(index); - return changeDetail; - } @Override public void withdraw(@Valid List ids) { @@ -346,6 +250,9 @@ public class DemandServiceImpl extends MPJBaseServiceImpl() { + dataService.updateById(dto,new DataOperationListener() { - @Override - public UpdateLngPngDemandDto before(DataOperationContent content) { - return null; - } + @Override + public UpdateLngPngDemandDto before(DataOperationContent content) { + return null; + } + + @Override + public UpdateLngPngDemandDto after(DataOperationContent content) { + callSubmit(dto,content); + return content.getObj(); + } + }); + }else { + dto.setId(IdUtil.getSnowflakeNextId()); + dto.setOrgId(dto.getId()); + dataService.insert(dto,new DataOperationListener() { + + @Override + public UpdateLngPngDemandDto before(DataOperationContent content) { + return null; + } + + @Override + public UpdateLngPngDemandDto after(DataOperationContent content) { + callSubmit(dto,content); + return content.getObj(); + } + }); + } + + + } - @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(); - } - }); + void callSubmit(UpdateLngPngDemandDto dto,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)); + } + }