日计划管理-客户需求

This commit is contained in:
2026-01-23 11:25:15 +08:00
parent 664579d041
commit 5ec3cedadf
4 changed files with 96 additions and 191 deletions

View File

@ -45,6 +45,7 @@ import com.xjrsoft.module.dayPlan.vo.LngPngDemandVo;
import com.pictc.utils.StringUtils; import com.pictc.utils.StringUtils;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -94,6 +95,8 @@ public class DemandController {
@ApiOperation(value = "新增LngPngDemand") @ApiOperation(value = "新增LngPngDemand")
@SaCheckPermission("demand:add") @SaCheckPermission("demand:add")
public R add(@Valid @RequestBody UpdateLngPngDemandDto dto){ public R add(@Valid @RequestBody UpdateLngPngDemandDto dto){
dto.setId(IdUtil.getSnowflakeNextId());
dto.setOrgId(dto.getId());
return R.ok(dataService.insert(dto,new DataOperationListener<UpdateLngPngDemandDto>() { return R.ok(dataService.insert(dto,new DataOperationListener<UpdateLngPngDemandDto>() {
@Override @Override
@ -161,15 +164,15 @@ public class DemandController {
return R.ok(); return R.ok();
} }
@PostMapping(value="/toChange") @GetMapping(value="/toChange")
@ApiOperation(value = "变更LngPngDemand") @ApiOperation(value = "变更LngPngDemand")
//@SaCheckPermission("demand:toChange") //@SaCheckPermission("demand:toChange")
public R toChange(@Valid @RequestParam Long id){ public R toChange(@Valid @RequestParam Long id){
LngPngDemand lngPngDemand = demandService.getByIdDeep(id); LngPngDemandVo res = demandService.getInfoById(id);
if (lngPngDemand == null) { if (res == null) {
return R.error("找不到此数据!"); return R.error("找不到此数据!");
} }
LngPngDemandVo res = BeanUtil.toBean(lngPngDemand, LngPngDemandVo.class); //LngPngDemandVo res = BeanUtil.toBean(lngPngDemand, LngPngDemandVo.class);
res.setId(null); res.setId(null);
res.setAlterSign("U"); res.setAlterSign("U");
res.setApproCode("WTJ"); res.setApproCode("WTJ");
@ -196,7 +199,7 @@ public class DemandController {
return R.ok(res); return R.ok(res);
} }
@PostMapping(value="/cancel") @GetMapping(value="/cancel")
@ApiOperation(value = "取消LngPngDemand") @ApiOperation(value = "取消LngPngDemand")
//@SaCheckPermission("demand:cancel") //@SaCheckPermission("demand:cancel")
public R cancel(@Valid @RequestParam Long id){ public R cancel(@Valid @RequestParam Long id){
@ -250,7 +253,7 @@ public class DemandController {
@PostMapping(value="/withdraw") @PostMapping(value="/withdraw")
@ApiOperation(value = "撤回LngPngDemand") @ApiOperation(value = "撤回LngPngDemand")
//@SaCheckPermission("demand:cancel") //@SaCheckPermission("demand:cancel")
public R withdraw(@Valid @RequestParam List<Long> ids){ public R withdraw(@Valid @RequestBody List<Long> ids){
demandService.withdraw(ids); demandService.withdraw(ids);
return R.ok(); return R.ok();
} }

View File

@ -1,21 +1,18 @@
package com.xjrsoft.module.dayPlan.entity; 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.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy; import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField; 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.TableId;
import com.baomidou.mybatisplus.annotation.Version; import com.baomidou.mybatisplus.annotation.TableName;
import com.github.yulichang.annotation.EntityMapping;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; 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("日计划-管道气-客户需求主键") @ApiModelProperty("日计划-管道气-客户需求主键")
@TableField(updateStrategy = FieldStrategy.IGNORED) @TableField(updateStrategy = FieldStrategy.IGNORED)
private Long demandId; private Long demandId;
@ -62,9 +56,6 @@ public class LngPngDemandPur implements Serializable {
* 采购合同-主信息主键 * 采购合同-主信息主键
*/ */
@ApiModelProperty("采购合同-主信息主键") @ApiModelProperty("采购合同-主信息主键")
@TableField(updateStrategy = FieldStrategy.IGNORED) @TableField(updateStrategy = FieldStrategy.IGNORED)
private Long kpId; private Long kpId;
@ -72,9 +63,6 @@ public class LngPngDemandPur implements Serializable {
* 合同-国内采购-管道气-上载点主键 * 合同-国内采购-管道气-上载点主键
*/ */
@ApiModelProperty("合同-国内采购-管道气-上载点主键") @ApiModelProperty("合同-国内采购-管道气-上载点主键")
@TableField(updateStrategy = FieldStrategy.IGNORED) @TableField(updateStrategy = FieldStrategy.IGNORED)
private Long kpppId; private Long kpppId;
@ -94,9 +82,6 @@ public class LngPngDemandPur implements Serializable {
* 比值(方/吉焦) * 比值(方/吉焦)
*/ */
@ApiModelProperty("比值(方/吉焦)") @ApiModelProperty("比值(方/吉焦)")
@TableField(updateStrategy = FieldStrategy.IGNORED) @TableField(updateStrategy = FieldStrategy.IGNORED)
private BigDecimal rateM3Gj; private BigDecimal rateM3Gj;
@ -104,9 +89,6 @@ public class LngPngDemandPur implements Serializable {
* 日指定量(吉焦)(客户填报) * 日指定量(吉焦)(客户填报)
*/ */
@ApiModelProperty("日指定量(吉焦)(客户填报)") @ApiModelProperty("日指定量(吉焦)(客户填报)")
@TableField(updateStrategy = FieldStrategy.IGNORED) @TableField(updateStrategy = FieldStrategy.IGNORED)
private BigDecimal qtyDemandGj; private BigDecimal qtyDemandGj;
@ -154,9 +136,6 @@ public class LngPngDemandPur implements Serializable {
* 创建人id * 创建人id
*/ */
@ApiModelProperty("创建人id") @ApiModelProperty("创建人id")
@TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.IGNORED) @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.IGNORED)
private Long createUserId; private Long createUserId;
@ -192,9 +171,6 @@ public class LngPngDemandPur implements Serializable {
* 部门id * 部门id
*/ */
@ApiModelProperty("部门id") @ApiModelProperty("部门id")
@TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.IGNORED) @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.IGNORED)
private Long deptId; private Long deptId;
@ -202,9 +178,6 @@ public class LngPngDemandPur implements Serializable {
* 数据权限id * 数据权限id
*/ */
@ApiModelProperty("数据权限id") @ApiModelProperty("数据权限id")
@TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.IGNORED) @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.IGNORED)
private Long ruleUserId; private Long ruleUserId;

View File

@ -9,6 +9,7 @@ import com.github.yulichang.extension.mapping.base.MPJDeepService;
import com.github.yulichang.extension.mapping.base.MPJRelationService; import com.github.yulichang.extension.mapping.base.MPJRelationService;
import com.xjrsoft.common.model.result.R; import com.xjrsoft.common.model.result.R;
import com.xjrsoft.common.page.PageOutput; 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.LngPngDemandPageDto;
import com.xjrsoft.module.dayPlan.dto.UpdateLngPngDemandDto; import com.xjrsoft.module.dayPlan.dto.UpdateLngPngDemandDto;
import com.xjrsoft.module.dayPlan.entity.LngPngDemand; import com.xjrsoft.module.dayPlan.entity.LngPngDemand;
@ -28,7 +29,7 @@ public interface IDemandService extends MPJBaseService<LngPngDemand>, MPJDeepSer
LngPngDemandVo getInfoById(Long id); LngPngDemandVo getInfoById(Long id);
List<LngPngDemandVo> compare(@Valid Long id); CompareResultVo<LngPngDemandVo> compare(@Valid Long id);
Long selectApprovedCount(Long id); Long selectApprovedCount(Long id);

View File

@ -10,6 +10,7 @@ import java.util.stream.Collectors;
import javax.validation.Valid; import javax.validation.Valid;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.JdbcTools;
import com.pictc.jdbc.model.JdbcParam; import com.pictc.jdbc.model.JdbcParam;
import com.pictc.utils.DataLogTools; import com.pictc.utils.DataLogTools;
import com.pictc.utils.ObjectDiffUtils;
import com.pictc.utils.StringUtils; import com.pictc.utils.StringUtils;
import com.xjrsoft.common.exception.BusinessException; import com.xjrsoft.common.exception.BusinessException;
import com.xjrsoft.module.datalog.service.DatalogService; 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.UpdateLngPngApproDto;
import com.xjrsoft.module.dayPlan.dto.UpdateLngPngDemandDto; import com.xjrsoft.module.dayPlan.dto.UpdateLngPngDemandDto;
import com.xjrsoft.module.dayPlan.entity.LngPngAppro; 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.LngPngDemandMapper;
import com.xjrsoft.module.dayPlan.mapper.LngPngDemandPurMapper; import com.xjrsoft.module.dayPlan.mapper.LngPngDemandPurMapper;
import com.xjrsoft.module.dayPlan.service.IDemandService; 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.LngPngDemandChangeDetailVo;
import com.xjrsoft.module.dayPlan.vo.LngPngDemandPurVo; import com.xjrsoft.module.dayPlan.vo.LngPngDemandPurVo;
import com.xjrsoft.module.dayPlan.vo.LngPngDemandVo; import com.xjrsoft.module.dayPlan.vo.LngPngDemandVo;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import shade.powerjob.com.google.common.collect.Lists; import shade.powerjob.com.google.common.collect.Lists;
@ -81,133 +87,31 @@ public class DemandServiceImpl extends MPJBaseServiceImpl<LngPngDemandMapper, Ln
} }
@Override @Override
public List<LngPngDemandVo> compare(@Valid Long id) { public CompareResultVo<LngPngDemandVo> compare(@Valid Long id) {
List<LngPngDemandVo> list = Lists.newArrayList(); List<LngPngDemandVo> voList = Lists.newArrayList();
List<LngPngDemandChangeDetailVo> mainChangeList = Lists.newArrayList(); LngPngDemandVo currentVo = this.getInfoById(id);
List<LngPngDemandChangeDetailVo> subListChangeList = Lists.newArrayList(); voList.add(currentVo);
LngPngDemand current = this.getByIdDeep(id);
if(current != null) {
LngPngDemandVo currentVo = BeanUtil.toBean(current, LngPngDemandVo.class);
list.add(currentVo);
List<LngPngDemandPur> currentPurList = current.getLngPngDemandPurList();
currentPurList = currentPurList.stream()
.sorted(Comparator.comparing(LngPngDemandPur::getSort))
.collect(Collectors.toList());
LambdaQueryWrapper<LngPngDemand> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<LngPngDemand> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(LngPngDemand::getOrgId, current.getOrgId()); queryWrapper.eq(LngPngDemand::getOrgId, currentVo.getOrgId());
queryWrapper.eq(LngPngDemand::getVerNo, current.getVerNo()-1); queryWrapper.eq(LngPngDemand::getVerNo, currentVo.getVerNo()-1);
LngPngDemand last = this.baseMapper.selectOne(queryWrapper); LngPngDemand last = this.baseMapper.selectOne(queryWrapper);
if(last != null) { if(last != null) {
compareMain(current,last,mainChangeList); LngPngDemandVo lastVo = this.getInfoById(last.getId());
LambdaQueryWrapper<LngPngDemandPur> queryPurWrapper = new LambdaQueryWrapper<>(); voList.add(lastVo);
queryPurWrapper.eq(LngPngDemandPur::getDemandId,last.getId());
queryPurWrapper.orderByAsc(LngPngDemandPur::getSort);
List<LngPngDemandPur> lastPurList = demandPurMapper.selectList(queryPurWrapper);
//增加了item
if(currentPurList.size() >= lastPurList.size()) {
for(int i=0;i<lastPurList.size();i++) {
compareSubList(currentPurList.get(i),lastPurList.get(i),subListChangeList,i);
}
}else {
for(int i=0;i<currentPurList.size();i++) {
compareSubList(currentPurList.get(i),lastPurList.get(i),subListChangeList,i);
}
}
last.setLngPngDemandPurList(lastPurList);
LngPngDemandVo lastVo = BeanUtil.toBean(last, LngPngDemandVo.class);
list.add(lastVo);
} }
currentVo.setMainChangeDetailList(mainChangeList); CompareResultVo<LngPngDemandVo> vo = new CompareResultVo<>();
currentVo.setSubListChangeDetailList(subListChangeList); LngPngDemandVo newBean = voList.get(0);
} vo.setNewBean(newBean);
return list; if (voList.size() > 1) {
} LngPngDemandVo oldBean = voList.get(1);
List<String> diffResultList = ObjectDiffUtils.compare(newBean, oldBean);
private void compareMain(LngPngDemand current, LngPngDemand last,List<LngPngDemandChangeDetailVo> changeList) { vo.setOldBean(oldBean);
vo.setDiffResultList(diffResultList);
String[] compareFields = {"datePlan","kName","pointDelyCode","qtyDemandGj","qtyDemandM3","priceSalesGj", }
"priceSalesM3","reply","note"}; return vo;
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<LngPngDemandChangeDetailVo> 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 @Override
public void withdraw(@Valid List<Long> ids) { public void withdraw(@Valid List<Long> ids) {
@ -346,6 +250,9 @@ public class DemandServiceImpl extends MPJBaseServiceImpl<LngPngDemandMapper, Ln
dto.setApproCode("SPZ"); dto.setApproCode("SPZ");
dto.setTimeSubmit(LocalDateTime.now()); dto.setTimeSubmit(LocalDateTime.now());
if(dto.getId() != null) { if(dto.getId() != null) {
if(dto.getOrgId() == null) {
dto.setOrgId(dto.getId());;
}
LngPngDemand lngPngDemand = this.getById(dto.getId()); LngPngDemand lngPngDemand = this.getById(dto.getId());
if (lngPngDemand == null) { if (lngPngDemand == null) {
throw new BusinessException(BusinessCode.of(10500,"找不到此数据!")); throw new BusinessException(BusinessCode.of(10500,"找不到此数据!"));
@ -355,38 +262,59 @@ public class DemandServiceImpl extends MPJBaseServiceImpl<LngPngDemandMapper, Ln
if(!"WTJ".equals(lngPngDemand.getApproCode()) && !"YBH".equals(lngPngDemand.getApproCode()) ) { if(!"WTJ".equals(lngPngDemand.getApproCode()) && !"YBH".equals(lngPngDemand.getApproCode()) ) {
throw new BusinessException(BusinessCode.of(10500,"审批状态变化,不能提交")); throw new BusinessException(BusinessCode.of(10500,"审批状态变化,不能提交"));
} }
dataService.updateById(dto,new DataOperationListener<UpdateLngPngDemandDto>() {
@Override
public UpdateLngPngDemandDto before(DataOperationContent<UpdateLngPngDemandDto> content) {
return null;
}
@Override
public UpdateLngPngDemandDto after(DataOperationContent<UpdateLngPngDemandDto> content) {
callSubmit(dto,content);
return content.getObj();
}
});
}else {
dto.setId(IdUtil.getSnowflakeNextId());
dto.setOrgId(dto.getId());
dataService.insert(dto,new DataOperationListener<UpdateLngPngDemandDto>() {
@Override
public UpdateLngPngDemandDto before(DataOperationContent<UpdateLngPngDemandDto> content) {
return null;
}
@Override
public UpdateLngPngDemandDto after(DataOperationContent<UpdateLngPngDemandDto> content) {
callSubmit(dto,content);
return content.getObj();
}
});
} }
dataService.insert(dto,new DataOperationListener<UpdateLngPngDemandDto>() {
@Override
public UpdateLngPngDemandDto before(DataOperationContent<UpdateLngPngDemandDto> content) {
return null;
}
@Override }
public UpdateLngPngDemandDto after(DataOperationContent<UpdateLngPngDemandDto> content) {
String sql = StringUtils.format("{? = call pc_{0}.f_save_submit(?,?)}", void callSubmit(UpdateLngPngDemandDto dto,DataOperationContent<UpdateLngPngDemandDto> content) {
content.getTableName()); String sql = StringUtils.format("{? = call pc_{0}.f_save_submit(?,?)}",
content.getTableName());
List<JdbcParam> 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));
}
List<JdbcParam> 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();
}
});
} }