日计划管理-客户需求
This commit is contained in:
@ -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<UpdateLngPngDemandDto>() {
|
||||
|
||||
@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<Long> ids){
|
||||
public R withdraw(@Valid @RequestBody List<Long> ids){
|
||||
demandService.withdraw(ids);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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<LngPngDemand>, MPJDeepSer
|
||||
|
||||
LngPngDemandVo getInfoById(Long id);
|
||||
|
||||
List<LngPngDemandVo> compare(@Valid Long id);
|
||||
CompareResultVo<LngPngDemandVo> compare(@Valid Long id);
|
||||
|
||||
Long selectApprovedCount(Long id);
|
||||
|
||||
|
||||
@ -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<LngPngDemandMapper, Ln
|
||||
}
|
||||
|
||||
@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());
|
||||
|
||||
public CompareResultVo<LngPngDemandVo> compare(@Valid Long id) {
|
||||
List<LngPngDemandVo> voList = Lists.newArrayList();
|
||||
LngPngDemandVo currentVo = this.getInfoById(id);
|
||||
voList.add(currentVo);
|
||||
LambdaQueryWrapper<LngPngDemand> 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<LngPngDemandPur> queryPurWrapper = new LambdaQueryWrapper<>();
|
||||
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);
|
||||
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();
|
||||
LngPngDemandVo lastVo = this.getInfoById(last.getId());
|
||||
voList.add(lastVo);
|
||||
}
|
||||
CompareResultVo<LngPngDemandVo> vo = new CompareResultVo<>();
|
||||
LngPngDemandVo newBean = voList.get(0);
|
||||
vo.setNewBean(newBean);
|
||||
if (voList.size() > 1) {
|
||||
LngPngDemandVo oldBean = voList.get(1);
|
||||
List<String> diffResultList = ObjectDiffUtils.compare(newBean, oldBean);
|
||||
vo.setOldBean(oldBean);
|
||||
vo.setDiffResultList(diffResultList);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
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<Long> ids) {
|
||||
@ -346,6 +250,9 @@ public class DemandServiceImpl extends MPJBaseServiceImpl<LngPngDemandMapper, Ln
|
||||
dto.setApproCode("SPZ");
|
||||
dto.setTimeSubmit(LocalDateTime.now());
|
||||
if(dto.getId() != null) {
|
||||
if(dto.getOrgId() == null) {
|
||||
dto.setOrgId(dto.getId());;
|
||||
}
|
||||
LngPngDemand lngPngDemand = this.getById(dto.getId());
|
||||
if (lngPngDemand == null) {
|
||||
throw new BusinessException(BusinessCode.of(10500,"找不到此数据!"));
|
||||
@ -355,9 +262,22 @@ public class DemandServiceImpl extends MPJBaseServiceImpl<LngPngDemandMapper, Ln
|
||||
if(!"WTJ".equals(lngPngDemand.getApproCode()) && !"YBH".equals(lngPngDemand.getApproCode()) ) {
|
||||
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
|
||||
@ -367,6 +287,16 @@ public class DemandServiceImpl extends MPJBaseServiceImpl<LngPngDemandMapper, Ln
|
||||
|
||||
@Override
|
||||
public UpdateLngPngDemandDto after(DataOperationContent<UpdateLngPngDemandDto> content) {
|
||||
callSubmit(dto,content);
|
||||
return content.getObj();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void callSubmit(UpdateLngPngDemandDto dto,DataOperationContent<UpdateLngPngDemandDto> content) {
|
||||
String sql = StringUtils.format("{? = call pc_{0}.f_save_submit(?,?)}",
|
||||
content.getTableName());
|
||||
|
||||
@ -384,9 +314,7 @@ public class DemandServiceImpl extends MPJBaseServiceImpl<LngPngDemandMapper, Ln
|
||||
if (StringUtils.isNotEmpty(error)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_DELETE_EXEC_ERROR, error));
|
||||
}
|
||||
return content.getObj();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user