Merge branch 'dev' of http://47.94.165.164:13000/geg-gas/geg-gas-pcitc into dev
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;
|
||||
|
||||
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.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ContentStyle;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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: 分页列表出参
|
||||
* @Author test01
|
||||
|
||||
@ -9,10 +9,6 @@ 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: 表单出参
|
||||
@ -298,5 +294,10 @@ public class LngPngDemandVo extends com.xjrsoft.common.model.base.BaseModel{
|
||||
*/
|
||||
@ApiModelProperty("lngPngDemandPur子表")
|
||||
private List<LngPngDemandPurVo> lngPngDemandPurList;
|
||||
|
||||
|
||||
private List<LngPngDemandChangeDetailVo> mainChangeDetailList;
|
||||
|
||||
private List<LngPngDemandChangeDetailVo> subListChangeDetailList;
|
||||
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user