Merge branch 'feature/DM/nflg-bom' of http://112.74.186.154:3000/nflj/nflg_project into feature/DM/nflg-bom

# Conflicts:
#	nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomParentService.java
This commit is contained in:
jing's 2024-03-05 20:51:59 +08:00
commit 863505362b
23 changed files with 185 additions and 52 deletions

View File

@ -660,4 +660,19 @@ public class DateUtils extends PropertyEditorSupport {
String result = sdf.format(Date.parse(str));
return result;
}
/**
* 在给定的日期上增加指定的时间单位数量
*
* @param date 初始日期操作的基础日期
* @param field 时间单位例如Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH等
* @param amount 要增加的数量可以为负数以表示减少
* @return 返回操作后的新日期
*/
public static Date add(Date date, int field, int amount) {
Calendar cal = getCalendar();
cal.setTime(date);
cal.add(field, amount);
return cal.getTime();
}
}

View File

@ -0,0 +1,40 @@
package com.nflg.product;
import com.nflg.product.util.DateUtils;
import org.junit.Test;
import java.util.Calendar;
import java.util.Date;
import static org.junit.Assert.assertEquals;
/**
* @author 曹鹏飞
* @date 2024-03-04 14:07:45
*/
public class DateTimeTest {
@Test
public void test1() {
Calendar calendar = Calendar.getInstance();
calendar.set(2024, 2, 4);
Date date1 = calendar.getTime();
Date d1 = DateUtils.add(date1, Calendar.DAY_OF_MONTH, 1);
System.out.println("d1: " + DateUtils.date2Str(d1, DateUtils.date_sdf.get()));
calendar.set(2024, 2, 5);
Date d2 = calendar.getTime();
System.out.println("d2: " + DateUtils.date2Str(d2, DateUtils.date_sdf.get()));
assertEquals(d1, d2);
}
@Test
public void test2() {
Calendar calendar = Calendar.getInstance();
calendar.set(2024, Calendar.FEBRUARY, 29);
Date date1 = calendar.getTime();
Date d1 = DateUtils.add(date1, Calendar.DAY_OF_MONTH, 1);
System.out.println("d1: " + DateUtils.date2Str(d1, DateUtils.date_sdf.get()));
calendar.set(2024, Calendar.MARCH, 1);
Date d2 = calendar.getTime();
System.out.println("d2: " + DateUtils.date2Str(d2, DateUtils.date_sdf.get()));
assertEquals(d1, d2);
}
}

View File

@ -1,24 +1,18 @@
package com.nflg.product.material.api.user.authority;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mysql.cj.log.Log;
import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.material.mapper.master.AuthorityRolePowerMapper;
import com.nflg.product.material.pojo.dto.AuthorityPowerDTO;
import com.nflg.product.material.pojo.dto.SaveMemuPermissionDTO;
import com.nflg.product.material.pojo.entity.AuthorityPowerEntity;
import com.nflg.product.material.pojo.query.AuthorityPowerQuery;
import com.nflg.product.material.pojo.vo.AuthorityMenuVO;
import com.nflg.product.material.pojo.vo.AuthorityPowerVO;
import com.nflg.product.material.service.AuthorityPowerService;
import com.nflg.product.material.service.AuthorityRolePowerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import nflg.product.common.constant.STATE;
import nflg.product.common.vo.ResultVO;
import org.omg.PortableInterceptor.LOCATION_FORWARD;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

View File

@ -1,7 +1,6 @@
package com.nflg.product.material.pojo.vo;
import lombok.Data;
import org.omg.CORBA.PRIVATE_MEMBER;
/**
* @decription

View File

@ -211,6 +211,14 @@ public class PBomApi extends BaseApi {
return ResultVO.success(bomNewPbomParentService.saveAllocationFactory(params));
}
@PostMapping("saveAllocationFactoryNew")
@ApiOperation("分工厂-批量保存保存")
@LogRecord(success = "PBom-分工厂-保存。操作结果:{{#_ret}}", bizNo = "",type = "PBom-分工厂-保存")
public ResultVO<Boolean> saveAllocationFactory(@Valid @RequestBody AllocationFactoryParam params){
return ResultVO.success(bomNewPbomParentService.saveAllocationFactoryNew(params));
}
@PostMapping("allocationFactoryForRel")
@ApiOperation("分工厂-规则匹配")
@LogRecord(success = "PBom-分工厂-规则匹配,物料编码:{{#bom.materialNo}}-版本:{{#bom.currentVersion}}-规则编码:{{#params.ruleGroupCode}} 操作结果:{{#_ret}}", bizNo = "{{#params.bomRowId}}",type = "PBom-分工厂-规则匹配")

View File

@ -0,0 +1,19 @@
package com.nflg.product.bomnew.pojo.dto;
import com.nflg.product.bomnew.service.BomNewLogService;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 分工厂
*/
@Data
public class AllocationFactoryParam {
List<SaveAllocationFactoryDTO> data;
@ApiModelProperty("是否设置下级 0-否 1-是")
private Integer setSubNode;
}

View File

@ -15,6 +15,9 @@ public class SaveAllocationFactoryDTO {
@NotNull(message = "bom明细行ID不能为空")
private Long rowId;
@ApiModelProperty("bom版本行ID")
private Long bomRowId;
@ApiModelProperty("生产工厂")
@NotNull(message = "生产工厂不能为空")
private String productionFactoryCode;

View File

@ -321,4 +321,18 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
private List<BomNewEbomParentVO> childNodes = Collections.emptyList();
private static final long serialVersionUID = 1L;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
BomNewEbomParentVO that = (BomNewEbomParentVO) o;
return rowId.equals(that.rowId);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), rowId);
}
}

View File

@ -10,6 +10,7 @@ import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* 原始BOM-列表
@ -206,8 +207,19 @@ public class BomOriginalListVO extends BaseMaterialVO {
private List<BomOriginalListVO> childNodes = Collections.emptyList();
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
BomOriginalListVO that = (BomOriginalListVO) o;
return rowId.equals(that.rowId);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), rowId);
}
private static final long serialVersionUID = 1L;
}

View File

@ -1,6 +1,5 @@
package com.nflg.product.bomnew.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
@ -14,14 +13,12 @@ import com.nflg.product.bomnew.pojo.entity.BomNewMbomParentEntity;
import com.nflg.product.bomnew.pojo.query.BomNewMbomParentQuery;
import com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO;
import com.nflg.product.bomnew.service.domain.MBom.IndexListTree;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@ -63,7 +60,7 @@ public class BomNewMbomParentService extends ServiceImpl<BomNewMbomParentMapper,
if (StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) {
page = this.getBaseMapper().indexListPage(new Page<>(query.getPage(), query.getPageSize()), query);
if (CollectionUtil.isNotEmpty(page.getRecords())) {
List<BomNewMbomMiddleVO> indexList = page.getRecords().stream().collect(Collectors.toList());
List<BomNewMbomMiddleVO> indexList = new ArrayList<>(page.getRecords());
page.getRecords().clear();
for (BomNewMbomMiddleVO item :

View File

@ -612,6 +612,31 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
return true;
}
@Transactional(rollbackFor = Exception.class)
public Boolean saveAllocationFactoryNew(AllocationFactoryParam params) {
VUtils.isTure(CollUtil.isEmpty(params.getData())).throwMessage("分配工厂数据为空");
//按分配的工厂分组
if(BooleanEnum.TRUE.equals(params.getSetSubNode()) ){
return saveAllocationFactory(params.getData());
}else {
params.getData().forEach(k->{
try {
List<BomNewPbomParentVO> allBom = this.getAllBomTree(k.getBomRowId());
List<Long> rowIds = allBom.stream().map(u -> u.getRowId()).collect(Collectors.toList());
if(CollUtil.isNotEmpty(rowIds)) {
pbomChildService.getBaseMapper().setProductionFactoryCode(k.getProductionFactoryCode(), rowIds);
}
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
});
}
return true;
}
public Boolean allocationFactoryForRel(AllocationFactoryForRelDTO params) throws ExecutionException, InterruptedException {
VUtils.isTure(StrUtil.isBlank(params.getRuleGroupCode())).throwMessage("规则编码不能为空");

View File

@ -10,39 +10,25 @@ import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.util.TypeUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.ImmutableList;
import com.mzt.logapi.context.LogRecordContext;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.base.core.vo.PageVO;
import com.nflg.product.bomnew.constant.BomConstant;
import com.nflg.product.bomnew.constant.EBomConstant;
import com.nflg.product.bomnew.constant.OptionalBomConstant;
import com.nflg.product.bomnew.mapper.master.OptionalMbomMaterialMapper;
import com.nflg.product.bomnew.pojo.dto.OptionalMbomMaterialAddDTO;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity;
import com.nflg.product.bomnew.pojo.entity.OptionalEbomConfigEntity;
import com.nflg.product.bomnew.pojo.entity.OptionalMbomMaterialEntity;
import com.nflg.product.bomnew.pojo.query.BomNewEbomMaterialQuery;
import com.nflg.product.bomnew.pojo.query.OptionalMbomMaterialListQuery;
import com.nflg.product.bomnew.pojo.query.OptionalMbomMaterialQuery;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
import com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO;
import com.nflg.product.bomnew.pojo.vo.OptionalMbomMaterialListVO;
import com.nflg.product.bomnew.pojo.vo.OptionalMbomMaterialVO;
import lombok.extern.slf4j.Slf4j;
import nflg.product.common.constant.STATE;
import nflg.product.common.vo.ResultVO;
@ -51,7 +37,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -73,7 +58,7 @@ public class OptionalMbomMaterialService extends ServiceImpl<OptionalMbomMateria
if (StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) {
page = this.getBaseMapper().indexListPage(new Page<>(query.getPage(), query.getPageSize()), query);
if (CollectionUtil.isNotEmpty(page.getRecords())) {
List<OptionalMbomMaterialListVO> indexList = page.getRecords().stream().collect(Collectors.toList());
List<OptionalMbomMaterialListVO> indexList = new ArrayList<>(page.getRecords());
page.getRecords().clear();
for(OptionalMbomMaterialListVO item :

View File

@ -3,7 +3,6 @@ package com.nflg.product.bomnew.service.domain.EBom;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.google.common.collect.ImmutableList;
@ -16,15 +15,14 @@ import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
import com.nflg.product.bomnew.service.BomNewEbomParentService;
import com.nflg.product.bomnew.service.MaterialMainService;
import com.nflg.product.bomnew.util.BomLevelUtil;
import com.nflg.product.bomnew.util.ListCommonUtil;
import com.nflg.product.bomnew.util.TreeUtils;
import com.nflg.product.bomnew.util.VUtils;
import lombok.Getter;
import lombok.Setter;
import nflg.product.common.constant.STATE;
import com.nflg.product.bomnew.util.ListCommonUtil;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
@ -143,9 +141,9 @@ public class CheckEBomException {
*/
private void checkOther() {
// List<CheckEBomExceptionDTO> checkEBomExceptionDTOS=new ArrayList<>();
List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
List<BomNewEbomParentVO> parents = ListCommonUtil.toDistinct( allBomDetail.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()),BomNewEbomParentVO::getBomRowId);
for (BomNewEbomParentVO parent : parents) {
List<BomNewEbomParentVO> child = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parent.getBomRowId())).collect(Collectors.toList());
List<BomNewEbomParentVO> child = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parent.getBomRowId())).distinct().collect(Collectors.toList());
//是否存在重复物料
List<BomNewEbomParentVO> hasMaterialNoList = child.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo())).collect(Collectors.toList());

View File

@ -83,7 +83,7 @@ public class EBomToPBom {
check();
//bom 提层
liftingLayer();
List<BomNewEbomParentVO> parentList = result.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
List<BomNewEbomParentVO> parentList = ListCommonUtil.toDistinct( result.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()),BomNewEbomParentVO::getBomRowId);
List<String> hasConvert=new ArrayList<>();
for (String facCode : facCodes) {
@ -100,7 +100,7 @@ public class EBomToPBom {
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode);
//子级
List<BomNewEbomParentVO> child = result.stream().filter(u -> u.getParentRowId().equals(vo.getBomRowId())).collect(Collectors.toList());
List<BomNewEbomParentVO> child = result.stream().filter(u -> u.getParentRowId().equals(vo.getBomRowId())).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(child)) {
//合并子级
List<BomNewEbomParentVO> mergeChild = mergeChild(child);

View File

@ -3,7 +3,6 @@ package com.nflg.product.bomnew.service.domain.EBom;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.Pair;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
@ -16,13 +15,13 @@ import com.nflg.product.bomnew.service.*;
import com.nflg.product.bomnew.util.VUtils;
import com.nflg.product.bomnew.util.VersionUtil;
import lombok.Getter;
import org.bouncycastle.asn1.x509.IetfAttrSyntax;
import org.bouncycastle.cms.PasswordRecipient;
import org.omg.CORBA.PRIVATE_MEMBER;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**

View File

@ -10,7 +10,6 @@ import com.nflg.product.bomnew.constant.EBomSourceEnum;
import com.nflg.product.bomnew.constant.EbomEditStatusEnum;
import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum;
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
import com.nflg.product.bomnew.pojo.dto.AddMaterialMainDTO;
import com.nflg.product.bomnew.pojo.dto.AddVirtrualMaterialDTO;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
@ -23,8 +22,6 @@ import com.nflg.product.bomnew.service.MaterialService;
import com.nflg.product.bomnew.util.VersionUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import org.apache.catalina.authenticator.jaspic.CallbackHandlerImpl;
import sun.security.krb5.internal.PAData;
import java.io.IOException;
import java.math.BigDecimal;

View File

@ -97,6 +97,8 @@ public class OriginalBomToEBomConvert extends BaseConvert {
//处理子级
List<BomOriginalListVO> bomParents = bomDetail.stream().filter(u -> u.getBomRowId() > 0 && ( OriginalStatusEnum.UN_CONVERT.equalsValue(u.getStatus()) || OriginalStatusEnum.REFERENCE.equalsValue(u.getStatus())) ).collect(Collectors.toList());
//去重
bomParents= ListCommonUtil.toDistinct(bomParents,BomOriginalListVO::getBomRowId);
for (BomOriginalListVO childParent : bomParents) {
hanlerDo(childParent);
this.hasHandlerParentIds.add(childParent.getBomRowId());
@ -109,7 +111,7 @@ public class OriginalBomToEBomConvert extends BaseConvert {
return;
}
//子节点
List<BomOriginalListVO> parentChild = bomDetail.stream().filter(u -> Objects.nonNull(u.getParentRowId()) && u.getParentRowId().equals(parentEnt.getBomRowId())).collect(Collectors.toList());
List<BomOriginalListVO> parentChild = bomDetail.stream().filter(u -> Objects.nonNull(u.getParentRowId()) && u.getParentRowId().equals(parentEnt.getBomRowId())).distinct().collect(Collectors.toList());
List<BomOriginalListVO> parentChildNoMaterilaNoList = parentChild.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
//无编码
if (StrUtil.isBlank(parentEnt.getMaterialNo())) {

View File

@ -13,10 +13,11 @@ import com.nflg.product.bomnew.pojo.vo.ReverseReportVO;
import com.nflg.product.bomnew.service.BomNewOriginalChildService;
import com.nflg.product.bomnew.service.RedisService;
import com.nflg.product.bomnew.util.ListCommonUtil;
import lombok.Getter;
import org.omg.CORBA.PRIVATE_MEMBER;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**

View File

@ -2,6 +2,7 @@ package com.nflg.product.bomnew.util;
import cn.hutool.core.collection.ListUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -57,4 +58,28 @@ public class ListCommonUtil extends ListUtil {
}
return list.stream().collect(Collectors.groupingBy(function));
}
/**
* 去重
* @param list
* @param identityFunc
* @return
* @param <T>
* @param <R>
*/
public static <T,R> List<T> toDistinct(List<T> list, Function<T, R> identityFunc){
List<T> result = new ArrayList<>();
Map<R,String> fidler=new HashMap<>();
list.forEach(k->{
if(!fidler.containsKey(identityFunc.apply(k))){
result.add(k);
fidler.put(identityFunc.apply(k),"1");
}
});
return result;
}
}

View File

@ -66,7 +66,7 @@
<if test="query.status!=null and query.status==1">
<if test="query.startDate!=null and query.startDate!='' and query.endDate!=null and query.endDate!=''">
<![CDATA[ and created_time >= #{query.startDate} and created_time <=#{query.endDate}]]>
<![CDATA[ and created_time between #{query.startDate} and DATE_ADD(#{query.endDate}, INTERVAL 1 DAY) ]]>
</if>
</if>
@ -88,7 +88,7 @@
<if test="query.status!=null and query.status==3">
<if test="query.startDate!=null and query.startDate!='' and query.endDate!=null and query.endDate!=''">
<![CDATA[ and sysn_sap_time >= #{query.startDate} and sysn_sap_time <=#{query.endDate}]]>
<![CDATA[ and sysn_sap_time between #{query.startDate} and DATE_ADD(#{query.endDate}, INTERVAL 1 DAY) ]]>
</if>
</if>

View File

@ -63,7 +63,7 @@
<if test="query.startDate!= null and query.startDate!= '' and query.endDate != null and query.endDate!= '' ">
<![CDATA[and t1.created_time >= #{query.startDate} and t1.created_time <= #{query.endDate} ]]>
<![CDATA[and t1.created_time between #{query.startDate} and DATE_ADD(#{query.endDate}, INTERVAL 1 DAY) ]]>
</if>
order by t1.created_time desc

View File

@ -42,7 +42,7 @@
</if>
<if test="query.startDate != null and query.startDate != '' and query.endDate != null and query.endDate != ''">
<![CDATA[ and created_time >= #{query.startDate} and created_time <= #{query.endDate}]]>
<![CDATA[ and created_time between #{query.startDate} and DATE_ADD(#{query.endDate}, INTERVAL 1 DAY) ]]>
</if>
<if test="query.realName != null and query.realName != ''">

View File

@ -78,7 +78,7 @@ row_id,parent_row_id,level_row_id,material_no,material_name,material_desc,drawin
</if>
<if test="query.startDate != null and query.startDate != '' and query.endDate != null and query.endDate != null">
<![CDATA[ and t1.created_time >= #{query.startDate} and t1.created_time <= #{query.endDate}]]>
<![CDATA[ and t1.created_time between #{query.startDate} and DATE_ADD(#{query.endDate}, INTERVAL 1 DAY) ]]>
</if>