日计划-客户需求-对比
This commit is contained in:
@ -0,0 +1,39 @@
|
|||||||
|
package com.xjrsoft.module.dayPlan.vo;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.xjrsoft.common.annotation.Trans;
|
||||||
|
import com.xjrsoft.common.enums.TransType;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title: 表单出参
|
||||||
|
* @Author test01
|
||||||
|
* @Date: 2026-01-15
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class LngPngDemandChangeDetailVo implements java.io.Serializable{
|
||||||
|
|
||||||
|
|
||||||
|
private String filedName;
|
||||||
|
|
||||||
|
private Boolean changeFlag = false;
|
||||||
|
/**
|
||||||
|
* 变更标识(I/U/D对原始计划的增改删)
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("变更标识(I/U/D对原始计划的增改删)")
|
||||||
|
private String alterSign;
|
||||||
|
|
||||||
|
private Integer subListIndex;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,18 +1,15 @@
|
|||||||
package com.xjrsoft.module.dayPlan.vo;
|
package com.xjrsoft.module.dayPlan.vo;
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import com.alibaba.excel.annotation.write.style.ContentStyle;
|
import com.alibaba.excel.annotation.write.style.ContentStyle;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import com.xjrsoft.common.annotation.Trans;
|
|
||||||
import com.xjrsoft.common.enums.TransType;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title: 分页列表出参
|
* @title: 分页列表出参
|
||||||
* @Author test01
|
* @Author test01
|
||||||
|
|||||||
@ -9,10 +9,6 @@ import com.xjrsoft.common.enums.TransType;
|
|||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title: 表单出参
|
* @title: 表单出参
|
||||||
@ -299,4 +295,9 @@ public class LngPngDemandVo extends com.xjrsoft.common.model.base.BaseModel{
|
|||||||
@ApiModelProperty("lngPngDemandPur子表")
|
@ApiModelProperty("lngPngDemandPur子表")
|
||||||
private List<LngPngDemandPurVo> lngPngDemandPurList;
|
private List<LngPngDemandPurVo> lngPngDemandPurList;
|
||||||
|
|
||||||
|
|
||||||
|
private List<LngPngDemandChangeDetailVo> mainChangeDetailList;
|
||||||
|
|
||||||
|
private List<LngPngDemandChangeDetailVo> subListChangeDetailList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,11 +70,7 @@ public class DemandController {
|
|||||||
@ApiOperation(value="根据id查询LngPngDemand信息")
|
@ApiOperation(value="根据id查询LngPngDemand信息")
|
||||||
@SaCheckPermission("demand:detail")
|
@SaCheckPermission("demand:detail")
|
||||||
public R info(@RequestParam Long id){
|
public R info(@RequestParam Long id){
|
||||||
LngPngDemand lngPngDemand = demandService.getByIdDeep(id);
|
return R.ok(demandService.getInfoById(id));
|
||||||
if (lngPngDemand == null) {
|
|
||||||
return R.error("找不到此数据!");
|
|
||||||
}
|
|
||||||
return R.ok(BeanUtil.toBean(lngPngDemand, LngPngDemandVo.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/datalog")
|
@GetMapping(value = "/datalog")
|
||||||
@ -182,7 +178,7 @@ public class DemandController {
|
|||||||
pdp.setAddSign("N");
|
pdp.setAddSign("N");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return add(temp);
|
return this.add(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value="/compare")
|
@GetMapping(value="/compare")
|
||||||
@ -190,7 +186,7 @@ public class DemandController {
|
|||||||
//@SaCheckPermission("demand:toChange")
|
//@SaCheckPermission("demand:toChange")
|
||||||
public R compare(@Valid @RequestParam Long id){
|
public R compare(@Valid @RequestParam Long id){
|
||||||
|
|
||||||
return null;
|
return R.ok(demandService.compare(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
|
|||||||
@ -113,10 +113,21 @@ public class PngMeasureSalesPurController {
|
|||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation(value = "保存LngPngMeasureSalesPur")
|
@ApiOperation(value = "保存LngPngMeasureSalesPur")
|
||||||
@SaCheckPermission("pngMeasureSalesPur:save")
|
@SaCheckPermission("pngMeasureSalesPur:save")
|
||||||
public R save(@Valid @RequestBody UpdateLngPngMeasureSalesPurDto dto){
|
public R save(@Valid @RequestBody List<UpdateLngPngMeasureSalesPurDto> dtoList){
|
||||||
UpdateLngPngMeasureSalesPurDto res = null;
|
|
||||||
res = dataService.insert(dto);
|
return R.ok(dataService.insertBatch(dtoList,new DataOperationListener<UpdateLngPngMeasureSalesPurDto>() {
|
||||||
return R.ok(res.getId());
|
|
||||||
|
@Override
|
||||||
|
public UpdateLngPngMeasureSalesPurDto before(DataOperationContent<UpdateLngPngMeasureSalesPurDto> content) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UpdateLngPngMeasureSalesPurDto after(DataOperationContent<UpdateLngPngMeasureSalesPurDto> content) {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
|
|||||||
@ -2,13 +2,17 @@ package com.xjrsoft.module.dayPlan.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseService;
|
import com.github.yulichang.base.MPJBaseService;
|
||||||
import com.github.yulichang.extension.mapping.base.MPJDeepService;
|
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.page.PageOutput;
|
import com.xjrsoft.common.page.PageOutput;
|
||||||
import com.xjrsoft.module.dayPlan.dto.LngPngDemandPageDto;
|
import com.xjrsoft.module.dayPlan.dto.LngPngDemandPageDto;
|
||||||
import com.xjrsoft.module.dayPlan.entity.LngPngDemand;
|
import com.xjrsoft.module.dayPlan.entity.LngPngDemand;
|
||||||
import com.xjrsoft.module.dayPlan.vo.LngPngDemandPageVo;
|
import com.xjrsoft.module.dayPlan.vo.LngPngDemandPageVo;
|
||||||
|
import com.xjrsoft.module.dayPlan.vo.LngPngDemandVo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title: service
|
* @title: service
|
||||||
@ -21,5 +25,9 @@ public interface IDemandService extends MPJBaseService<LngPngDemand>, MPJDeepSer
|
|||||||
|
|
||||||
PageOutput<LngPngDemandPageVo> queryPage(LngPngDemandPageDto dto);
|
PageOutput<LngPngDemandPageVo> queryPage(LngPngDemandPageDto dto);
|
||||||
|
|
||||||
|
LngPngDemandVo getInfoById(Long id);
|
||||||
|
|
||||||
|
List<LngPngDemandVo> compare(@Valid Long id);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,18 @@
|
|||||||
package com.xjrsoft.module.dayPlan.service.impl;
|
package com.xjrsoft.module.dayPlan.service.impl;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
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.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||||
@ -10,12 +20,17 @@ import com.xjrsoft.common.page.ConventPage;
|
|||||||
import com.xjrsoft.common.page.PageOutput;
|
import com.xjrsoft.common.page.PageOutput;
|
||||||
import com.xjrsoft.module.dayPlan.dto.LngPngDemandPageDto;
|
import com.xjrsoft.module.dayPlan.dto.LngPngDemandPageDto;
|
||||||
import com.xjrsoft.module.dayPlan.entity.LngPngDemand;
|
import com.xjrsoft.module.dayPlan.entity.LngPngDemand;
|
||||||
|
import com.xjrsoft.module.dayPlan.entity.LngPngDemandPur;
|
||||||
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.LngPngDemandChangeDetailVo;
|
||||||
import com.xjrsoft.module.dayPlan.vo.LngPngDemandPageVo;
|
import com.xjrsoft.module.dayPlan.vo.LngPngDemandPageVo;
|
||||||
|
import com.xjrsoft.module.dayPlan.vo.LngPngDemandVo;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import shade.powerjob.com.google.common.collect.Lists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title: service
|
* @title: service
|
||||||
@ -47,6 +62,143 @@ public class DemandServiceImpl extends MPJBaseServiceImpl<LngPngDemandMapper, Ln
|
|||||||
return pageOutput;
|
return pageOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LngPngDemandVo getInfoById(Long id) {
|
||||||
|
LngPngDemand lngPngDemand = this.getByIdDeep(id);
|
||||||
|
if (lngPngDemand == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return BeanUtil.toBean(lngPngDemand, LngPngDemandVo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LngPngDemandVo> compare(@Valid Long id) {
|
||||||
|
List<LngPngDemandVo> list = Lists.newArrayList();
|
||||||
|
List<LngPngDemandChangeDetailVo> mainChangeList = Lists.newArrayList();
|
||||||
|
List<LngPngDemandChangeDetailVo> subListChangeList = Lists.newArrayList();
|
||||||
|
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<>();
|
||||||
|
queryWrapper.eq(LngPngDemand::getOrgId, current.getOrgId());
|
||||||
|
queryWrapper.eq(LngPngDemand::getVerNo, current.getVerNo()-1);
|
||||||
|
LngPngDemand last = this.baseMapper.selectOne(queryWrapper);
|
||||||
|
if(last != null) {
|
||||||
|
compareMain(current,last,mainChangeList);
|
||||||
|
LambdaQueryWrapper<LngPngDemandPur> queryPurWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryPurWrapper.eq(LngPngDemandPur::getDemandId,last.getId());
|
||||||
|
queryPurWrapper.orderByAsc(LngPngDemandPur::getSort);
|
||||||
|
List<LngPngDemandPur> lastPurList = demandLngPngDemandPurMapper.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);
|
||||||
|
currentVo.setSubListChangeDetailList(subListChangeList);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void compareMain(LngPngDemand current, LngPngDemand last,List<LngPngDemandChangeDetailVo> 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<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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user