This commit is contained in:
2026-01-20 17:38:15 +08:00
7 changed files with 241 additions and 23 deletions

View File

@ -70,11 +70,7 @@ public class DemandController {
@ApiOperation(value="根据id查询LngPngDemand信息")
@SaCheckPermission("demand:detail")
public R info(@RequestParam Long id){
LngPngDemand lngPngDemand = demandService.getByIdDeep(id);
if (lngPngDemand == null) {
return R.error("找不到此数据!");
}
return R.ok(BeanUtil.toBean(lngPngDemand, LngPngDemandVo.class));
return R.ok(demandService.getInfoById(id));
}
@GetMapping(value = "/datalog")
@ -182,7 +178,21 @@ public class DemandController {
pdp.setAddSign("N");
}
}
return add(temp);
return R.ok(dataService.insert(temp,new DataOperationListener<UpdateLngPngDemandDto>() {
@Override
public UpdateLngPngDemandDto before(DataOperationContent<UpdateLngPngDemandDto> content) {
return null;
}
@Override
public UpdateLngPngDemandDto after(DataOperationContent<UpdateLngPngDemandDto> content) {
lngPngDemand.setLastVerSign("N");
demandService.updateById(lngPngDemand);
return null;
}
}));
}
@GetMapping(value="/compare")
@ -190,7 +200,7 @@ public class DemandController {
//@SaCheckPermission("demand:toChange")
public R compare(@Valid @RequestParam Long id){
return null;
return R.ok(demandService.compare(id));
}
@DeleteMapping

View File

@ -113,10 +113,21 @@ public class PngMeasureSalesPurController {
@PostMapping
@ApiOperation(value = "保存LngPngMeasureSalesPur")
@SaCheckPermission("pngMeasureSalesPur:save")
public R save(@Valid @RequestBody UpdateLngPngMeasureSalesPurDto dto){
UpdateLngPngMeasureSalesPurDto res = null;
res = dataService.insert(dto);
return R.ok(res.getId());
public R save(@Valid @RequestBody List<UpdateLngPngMeasureSalesPurDto> dtoList){
return R.ok(dataService.insertBatch(dtoList,new DataOperationListener<UpdateLngPngMeasureSalesPurDto>() {
@Override
public UpdateLngPngMeasureSalesPurDto before(DataOperationContent<UpdateLngPngMeasureSalesPurDto> content) {
return null;
}
@Override
public UpdateLngPngMeasureSalesPurDto after(DataOperationContent<UpdateLngPngMeasureSalesPurDto> content) {
return null;
}
}));
}
@PutMapping

View File

@ -2,13 +2,17 @@ package com.xjrsoft.module.dayPlan.service;
import java.util.List;
import javax.validation.Valid;
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.common.model.result.R;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.module.dayPlan.dto.LngPngDemandPageDto;
import com.xjrsoft.module.dayPlan.entity.LngPngDemand;
import com.xjrsoft.module.dayPlan.vo.LngPngDemandPageVo;
import com.xjrsoft.module.dayPlan.vo.LngPngDemandVo;
/**
* @title: service
@ -20,6 +24,10 @@ import com.xjrsoft.module.dayPlan.vo.LngPngDemandPageVo;
public interface IDemandService extends MPJBaseService<LngPngDemand>, MPJDeepService<LngPngDemand>, MPJRelationService<LngPngDemand> {
PageOutput<LngPngDemandPageVo> queryPage(LngPngDemandPageDto dto);
LngPngDemandVo getInfoById(Long id);
List<LngPngDemandVo> compare(@Valid Long id);
}

View File

@ -1,8 +1,18 @@
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.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;
@ -10,12 +20,17 @@ import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.module.dayPlan.dto.LngPngDemandPageDto;
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.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;
import lombok.AllArgsConstructor;
import shade.powerjob.com.google.common.collect.Lists;
/**
* @title: service
@ -47,6 +62,143 @@ public class DemandServiceImpl extends MPJBaseServiceImpl<LngPngDemandMapper, Ln
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;
}
}